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 app 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.
Related
I am developping my first application on iOS. I am on this language since few days and I am going to share this application in Apple Store ASAP. But I have a big question around architecture.
Currently, I have with about 40 different type of Views, others components and a lot of PNG (30x30). I know that I can reduce considerably the number of Views through the development of a small framework but as it's my first learning-by-practice application, I wanted to move on quickly about all standards components and to start this development without architecture, reusables class or design pattern ... without think too hard.
To be short, I am wondering about the real size of applications in production and the performances. Have we got some constraints with:
Apple Store (upload apps)
Ram Capacity of iPhone during using
Download application from apple store for the user
etc...
Basicly, is it acceptable to have with about 40 screens for an iPhone Application?
Best regards.
There is a limit of 50 MB for over-the-air downloads.
Number of screens is probably not going to be a problem. The amount of executable code associated with each screen is probably not going to be significant. The bigger issue is how much PNG data you are going to have embedded in the app. A single 30x30 PNG isn't very big. 40 of them probably won't very big (depending on how well they compress). But if you have dozens of them per screen, or if you have a big hi-res background image for each screen, then the total amount of data could get big.
My advice would be to just start developing everything in the most straightforward way you can. Don't worry about sizes until you have some evidence that it may be a problem. And do a lot of testing on an actual device (don't rely on the Simulator) running whatever the oldest OS version is that you are willing to support.
I have developed a server based app for iPhone. But according to client requirements and to avoid overloading on server side, i am required to store data on local end. It is all text and typically 2-4 MB in size.
For this i'm using NSUserDefaults instead of sqlite or CoreData.
The app has been tested successfully for around 2-3 months during it's development as well as post development testing and never shown any type of inconsistency in data storage, updation or deletion on any sort of iphone device from iphone 3G - iphone 4S.
Now there is an incosistency issue in the live app, when user leave the app idle on a screen for around 15-20 minutes and doesn't press home button means app is not in the background.
In this case, data seems to be lost.
But as soon as refresh app, in that case data appears again & app starts functioning normal again.
Here lies the main problem that when i'm refreshing, i'm doing nothing but only fetching fresh data from the server it can be simply one to five records or nothing at all.
Then app is refreshed, all of the records are shown & it functions normally.
I have been trying to spot the issue for around 3 days, and it's not happening on my device (iPhone 4S). As far as i can think, it seems to be problem with the old devices.
Previously in testing, none of this happened on old or new devices.
My questions are -
a) Is this an incosistency in my coding?
b) Are NSUserDefaults not trustworthy for database management for live apps?
c) Is it a device version specific problem related to NSUserDefaults?
Anybody faced/facing the problem with NSUserDefaults??
Please suggest me something i can do for this or tell me i have to do all the database work again for the next version using sqlite or CoreData.
Anyhow this is critically important and needs to be fixed.
Any help is appreciated in advance.
As my suggestion for you please introduce the Sqlite database integration because of the when the short size of the data store and of cause it's good rather then the Sqlite but it's not working into large number of the data that time must use the Sqlite or coredata.
so i suggest to use the Sqlite data and coredata.
I need to write an app to run on iPhone, iPad, Android phones & tablets. WinPhone 7 and desktop browsers would also be nice, but not necessary. I'm a desktop/Silverlight developer, but it seems this is a job for HTML 5 & javascript. Right?
I'm looking at Sencha touch, jquery, and amplify.js to simplify my life. My app has to be available in app stores, so I'm looking at PhoneGap to help with that.
The app needs to work offline which means I have need for local storage of about 10 megs. I don't know how to deal with this requirement because all the local storage options seem to top off at 5 megs.
Any ideas about how to deal with this? (Or any suggestions as to a better approach or libraries?)
I would try your best to get your app down to less than 5 Mb. This means perhaps compression of some sort before locally storing, perhaps only having the essential features available offline, and optimizing your data such that you can reduce any redundancy. Even after all of this, you are still dependent on whether or not the user's browser allows local storage, and whether it allows 5 Mb of it.
As per an answer on a question earlier today, the Web SQL Database spec is your friend here, at least on iOS 4.3
In an iPhone iOS4 app containing an existing SQLite database (i.e. there at compile time), how secure is the data in the SQLite database?
For example, is it worth encrypting an SQLite database (using the sqlite3_key(...) method sold under license)?
It is secured until the iPhone is jailbreaked. After jailbreak one can go to your database and can copy it to his desktop and then can see your data. So I think if you have very important data then you should encrypt your database
First question you have to answer is how valuable is your data? That somewhat determines how much time a hacker is willing to spend trying to get at it. Security is a complex subject and you could spend days researching IOS security. It depends heavily on the IOS version, with IOS 4 being the first release that has a decent chance of being really secure. First off nothing is secure unless your device is locked. Also, your database is NOT encrypted even if the device is locked unless you set data protection flags in your code. Sandbox doesn't help you here at all really, except to protect one apps data from another. A hacker with your device will jailbreak it and install an SSH server and at that point can pretty much do whatever they want, including brute-force passcode breaking attempts. If an IOS 4 device was locked with a decent passcode and you set data protection on your database, you are probably ok with counting on the IOS hardware encryption. But can you depend on users to set a decent passcode? The default simple passcode is only 4 digits - not that great. And will they all be IOS 4+ users? If not, you'll need your own encryption on the database. Just don't store the key anywhere, cuz hackers will find it. And while you are considering security in your coding, consider that hackers can also decompile and run a modified version of your app.
AFAIK data are physically encrypted on iOS 4.x devices. Add to that the fact that application are sandboxed, it's a fairly secure system.
I am building an iPhone app that contains medical information for medical professionals.
The data has a sort of taxonomy which is easily represented in the form of e.g. a mind map on a piece of paper. On the device, the idea is to navigate through a series of items in table views to get to a detail view with text and picture information. The no of child views/nodes varies from 1-4, and the number of items on each table view varies from 2 to 20. The detail items/views are about 120 in total.
Now, I have reasonably strong Obc-C/Cocoa skills (mostly mac), but have about zero experience from working with actual databases. So far, I have hard coded the information in nested NSArray/NSDictionary structures (much the way Apple demonstrates in its table view tutorial). This has obvious disadvantages, and I am considering swithcing to use some sort of database instead.
How would you, experienced iPhone programmers, solve a problem like this? SQLite database? Base app on Core Data?
Thankful for all sorts of help and suggestions.
-Gregor, Sweden
edit: implemented navigation/table view hierarchy with plist. Works like a charm. Will look into core data, if not for this project then for another with larger amounts of data.
I've created an app with an SQLite3 backend that worked out quite well. Performance was good.
If I were to start a new project from scratch, I'd definitely look at Core Data, as long as it's okay the project only runs on 3.0+ devices, as Core Data is a new feature in 3.0.
Ask your client if it's a big deal that the app not support 2.2.1 (last I looked at AdMob, that's still about 25% of iPhone users and 50% of iPod Touch users). If it is a big deal, then your answer is forced upon you.
Core Data in the iPhone 3.0 SDK. Adoption rates of the 3.0 SDK are huge! It's a software upgrade, free on iPhone. Hardware updates of Open GL ES 2.0 are more costly, people are slower to adopt the new hardware. But research online shows adoption of 3.0 is high.
Improved performance, uses SQL Lite underneath, and it's cross platform to Mac OSX. Lots of how to's out there for it as well.
// :)
CoreData on the iPhone makes this trivial, have a look at the Introduction Tutorial, then take a look at some of the other examples (there's complete versions of the tutorial app and the extended versions in the Dev Centre).
Look into RDF and OWL, you might find some C libs to handle data in those formats, which I think is more adequate than trying to fit graphs into a relational database.