I am new to iphone development. I am currently doing a restaurant app which takes data from a database. How can we store the data in a DB on iphone through our ap开发者_JS百科p so that it would even work offline?
You should use SQLite. Since the database is just a file, you can add the 50 MB file to your application, and that's it. SQLite's performance on the iPhone is good, in my experience, although YMMV depending on your exact table layout and indexes.
Just remember to keep a keen eye on how much data you fill it with:
Although 50 MB is way below the limit, be aware that a 50 MB application will take some time to download for people, and people cannot install it from the AppStore without either a WiFi connection or iTunes.
Also, applications that "grow" in size too rapidly after you install them can become unpopular on the smaller devices.
Here is a tutorial
Yes, SQLite is your best bet. Apple uses SQLite a lot in iOS 'internally' (DB for text messages.etc), so Apple must've put a lot of effort into optimising SQLite on iOS.
For Restaurant app, you can also use plist as a database. This is because you will only have a primitive datatypes and will be easy to handle with plist.
精彩评论