1

I have built an android app and now its time to built an IOS app. I am very new to IOS App development. I managed to done all the UI design parts and i am coding the backend part. In my application i am using Sqlite database and has many View Controllers each View talks to database. So i would like to have one Class(Java) which take care about the creating,inserting,deleting etc. If i need to get data from database then i have to call that class to access the database. Is there any way to do like this.

Or

I would like to know how to create sqlite database in a efficient way. Because my app fully based on database.

Thanks for your help guys.

1 Answer 1

9

There are two main ways to create a database:

  1. Use CoreData. In this case you should read manuals on CoreData, it is pretty complicated. But if you plan to use iCloud in future, I recommend you to use CoreData.

  2. Create db manually and not use CoreData.

The most efficient way in second case is to use a database manager for SQLite. For example, SQLite manager extension for Firefox.

There are more programs for this, but this is free one, that I use myself.

To work with database use FMDB wrapper over SQLite.

Nice tutorial for second approach.

Sign up to request clarification or add additional context in comments.

10 Comments

Thanks for your answer.. I am looking for any tutorial or example for second approach..
@Vinoth, you don't do database operations in views, you do them in your models. I suggest you to do some reading on MVC and understand how that works in xcode for iOS programming. Also, for sqlite database in your case, it would be much easier to use a database wrapper like wzbozon suggested.
@Vinoth: I found two simple ones: icodeblog.com/2011/11/04/… and highoncoding.com/Articles/… in terms of how to use the FMDB. Unfortunately, I personally never used FMDB before for my project, but i know it is pretty popular and reliable. I suggest you use SQLite manager firefox extension so you can create the database from GUI instead of using command line
@Vinoth: Sorry I cannot find a tutorial specifically about MVC styled SQLite app, but it is really just seem idea as other MVC apps. You create a class named DBOperationModel or something else, put all your DB operation code there. In your view controller, add a DBOperationModel object (for example name it dbWorker) as your view controller class field and make it a property. Then every time if you do db operations, you can do [self.dbWorker saveCarInfo] or some other methods you defined in your DBOperationModel. You got the idea.
@Vinoth: If you are looking for a good tutorial about MVC and iOS programming, check iPad and iPhone Application Development iTunes U free courses here: itunes.apple.com/us/itunes-u/… It is a very awesome class and at the very beginning, the professor explained very well on MVC and how you can build your app in a MVC fashion.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.