Use SQLite, plist, or something else? - sql

This is more of an opinion question than technical.
I am writing a basic app to get into UIKit, MapKit etc. I want to store some basic information such as location data, some strings etc, nothing crazy and not too many (several hundred). I wondered if I should go with SQLite or use plist files? I will release app updates, so don't want anything where data would be lost.
I'm leaning towards SQLite, but wanted to ask the opinion of people in the know first.
If you'd like to know more about the app to help make a decision, just holler. :)

You could use NSUserDefaults. They are simple to use and you can create them on the fly. If the user deletes the app, the prefs will be deleted, but if they simply install a new version on top, the prefs will remain.

A really good method to store persistent data on iOS devices is the Core Data framework. Check out this tutorial for a good introduction. There is also a good comparison here of the different data storage types. Hope that helps!

Related

Whats the best technology for storing data on my app ? [duplicate]

This question already has answers here:
Working with data in iOS Apps (What to choose? NSData, CoreData, sqlite, PList, NSUserDefaults)
(2 answers)
Closed 9 years ago.
Really straightforward description of my app; it is a simple app that display for the consumer questions and the user must answer the question I attempted to store the questions on a simple txt file and luckily I got a positive consequences,However I thought perhaps I should come with another way to store my data and I been very curious about using Core Data since it might be better for my app and for me as well since I'll gain more skills and information on iOS programming. To be honest I'm new to the iOS world and never used Core Data before.Yesterday I started studying the library that Apple provides to the public and what I found out that I can't access or add data on my NSManagedObjectcontext unless adding some lines of code such as the insert method and fetching the data. correct me please if what I mentioned earlier was wrong and lastly my question is should I use core data technology on my app? I'll be pleased to get more tips,info and great sources from you world.
As a beginner, you'll probably have an easier time with plists than with Core Data (which has some learning curve, and you'll need to write, and understand, some code to make it work).
With plists, you can save an NSArray or an NSDictionary as a file (and read that file when needed). You can also create a plist with some data and include it into your app (e.g. if you have a set of questions you want to include). Check out this tutorial.
Of course, once you need to implement data storage in a real, production app, you need to understand the tradeoffs between all the different persistence mechanisms that iOS provides.
Core Data can be made more approachable by using a tool such asmogenerator which will help abstract from a lot of the more in-depth stuff. Good stuff for wanting to do things 'right' and to progress your knowledge, but maybe the best way to do this is to keep it simple, get it working and move to something more in-depth if you start hitting walls?
Looks like they are trying to close this so hope this helps

Working on a Core Data store on two computers at the same time (or making sure it is only open on one computer at the same time)

Can I somehow work on two computers with the same Core Data store? This could, I presume, lead to some incompatibilities during saving. What is the best way to deal with this?
Also, let's say I want to avoid the pain of having to worry about this. How would I make sure that only one computer can work on a particular Core Data store at the same time?
Incidentally, you can work on multiple devices on the same store with one of Apple's own core technologies. It's called iCloud.
Sure, technically speaking there are several copies of the store on the devices as well as the logs in iCloud, but the effect would be the same.
Fortunately, iCloud syncing includes some clever mechanism to merge multiple versions if possible (if not, you have to decide which one to give preference).
Only caveat: in my experience iCloud with Core Data has been far from reliable when using the published information for implementation.
From my own experience with Core Data I do not believe that the framework was designed to be used in a multi user (or distributed) environment. I found this interesting post on CocoaBuilder which might help you shape your thoughts on the matter. It's dated July 2012, so it's pretty recent and also discusses some interesting other technologies that are available.

Working with data in iOS Apps (What to choose? NSData, CoreData, sqlite, PList, NSUserDefaults)

when I develop an iPhone App (Time Tracker, ToDoList etc) I never know whats the best way to deal with the data. Once I used a plist, next time sqlite or CoreData.
How do you decide whats the best for your project?
(Only talking about data management)
For Example if you want to develop:
Time Tracker App > Is PList your choice?
RSS Reader App > CoreData?
Photo App > sqlite?
EMail Client > ?
For a beginner can you point me roughly to proper directions?
(I know it depends a lot on the App and what you like to do with
it but any thought will help)
I'm far away from developing complicated apps, they are still pretty simple.
Thanks for help,
Marc
You can use these rules of thumb to decide what storage model will work for your app.
If the data fits in memory entirely and is relatively unstructured, use plist
If the data fits in memory entirely and has tree-like structure, use XML
If the data does not fit in memory and has a structure of a graph, and the app does not need extraordinary query capabilities, use Core Data
If the data does not fit in memory, has a complex structure, or the app benefits from powerful query capabilities provided by relational databases, use sqlite
If the data must be secret (e.g. a password), use keychain.
Note that these choices often overlap, because multiple storage models will fit the same app. Your final decision depends on your personal preferences - you pick a technology that you understand better.
There was a very good question about sqlite vs. Core Data on Stack Overflow, you may want to read through the answers to that question.
My rule of thumb for each of those would be:
Time Tracker App > Core Data
RSS Reader App > Core Data
Photo App > Core Data
EMail Client > Core Data
Though in each case there would be things you would store on the file system. For instance, the photo app would obviously put the actual photos on the file system. The text of the emails would be on the file system etc. The actual RSS messages might be text files too, but with meta data in Core Data objects.
At some point, you might find that the data you are storing is outgrowing the scalability of Core Data. At that point you would consider moving to SQLite.
The point is that Core Data is so easy to use and so superior to the alleged lighter weight alternatives, why wouldn't you use it?

iOS - updating user flow without app update

I'm looking at designing and building out a system that would allow A/B testing of different flows in an iOS app (e.g. registration flow, log-in flow, purchasing flow).
A system that comes to mind initially looks like:
app pings server, server responds giving list of resources (which could include some links to xib files)
if the user does not have those xibs on disk, download them and save them to disk
when the view controller is presented, load from the xib if it has been downloaded (else default to the one the app was shipped with)
Does anyone have any thoughts on this idea or any insights on this system?
NOTE: I am not trying to implement a system where I can add new features. Right now, I'm focusing on changing flows, like the text and views a user will see. I'm not looking into a discussion of whether this violates the App Store rules, but if you would like to do so - go for it!
This is possible, but I don't know if I would download XIBs to the device. Seems a little risky to me.
Apple did a talk at WWDC 2010 where they address this exact issue, and they recommend building the interface using (more or less) Plists or JSON to describe the UI elements and their functions, and building up the views dynamically. It's well worth watching as it brings up a lot of smaller issues that aren't immediately obvious, but it requires a developer account to access it).
This would be an interesting system to use. I wonder if one could write a shell script to replace the old binary of an app with a new one. I know it would probably be more complicated then just that, but it would be cool to do. I would definitely use this for in house apps, or personal tools. Its to bad the apple wouldn't allow it, unless someone could secretly slip it past them :-)
I say go for it. You seem to have a pretty good idea of what you want to do and how you want to do it. Changing the UI based on responses from a server isn't uncommon, but I guess downloading xib files from the server is. I don't see why it wouldn't work though and I don't think it would be rejected by Apple, but you never know.

What is something you wish you had known sooner about the iPhone SDK?

I'm interested in picking up some tips and tricks while learning about the SDK. What I am looking for something that you wish you had known getting started that would have benefited you now.
don't use a DOM parser, but a SAX parser. (Memory issues / speed).
if you use custom table cells, don't add too many views. (Slow scrolling issues)
if you add views to table cells, like labels, you may want to make their background opaque.
the generated table view code defeats the MVC paradigm. Think about your data model, and implement an UITableViewDataSource. Really.
One of the things I wish I knew at the very beginning was how to download data in a non-blocking way, specifically using NSURLConnection. The first versions of my apps suffered somewhat because I was using things like dataWithContentsOfURL:, which isn't a great idea on the iPhone, since you're never really sure what the network environment will be like for your users. To make it worse, I was testing over a fiber connection at home with an iPod touch, when a large number of my users were using Edge on their iPhones.
If you want to use SQLite, go with either Core Data (available in 3.0) or FMDatabase (Flying Meat). My first two apps, I wrote a customer wrapper and bound directly to SQLite. I am currently using FMDatabase with a new application and have found the experience much nicer.
In the case of a lot of developers, including Google, I'm sure they wish they knew their app would be rejected once complete.
CoreData Bindings is not supported on the phone.
Use the Clang Static Analyzer
http://clang-analyzer.llvm.org/
It's great for finding reference counting issues -- I have never seen a false positive.
Regarding the table view speed check out Loren Brichter's blog post http://blog.atebits.com/2008/12/fast-scrolling-in-tweetie-with-uitableview/