0

I'm really to new to iOS development. I've read through a couple of beginners books, and am currently going through the Standford course offered through iTunes.

I'm just a beginner, but I'm really particular about learning things correctly from the start. A lot of what I've learned through books or online doesn't seem to adhere to "best-practices" - which I understand, best-practice may be beyond the level of what's currently being taught, but I still hate learning things that are wrong only to have to relearn them later.

I was hoping that someone could offer me some advice on how to correctly store data in an app. That is, if I'm dynamically generating table cells from an array or dictionary what's the best way to store the data that array or dictionary came from?

If I were, say, displaying a list of articles via a table, and I'd like to be able to easily update that list with an app update at some point I'm assuming I wouldn't want to hard-code that list directly into a model, but get that data from elsewhere.

The examples I've learned from all show the use of plists, but then say that you would never actually do this with a plist in a real application. I'm not looking for how to do what I'm asking, just hoping that someone can point me in the right direction... Like, would you use SQLite?.. would it be best to parse a web source if your content was coming from the net?

I'm just trying to figure out the best way to do it. I realize there's no real "best" way to do it, but I've noticed a huge difference between sample code I see from some tutorials on the net and sample code from Apple - maybe I'm wrong, but I'm assuming Apple's code samples are well-written code.

4
  • Plists are great for a whole lot of use cases. Can you give us a link where it says that "you would never actually do this with a plist in a real application"? A good rule of thumb in my opinion is: if you have static data (not user-editable) that is small enough to comfortably fit in memory completely and you don't need to search that data, plists are the way to go. If the amount of data is huge and/or you need search and/or you want something that's user-editable, going with SQLite or Core Data can make more sense. Commented Mar 2, 2012 at 19:10
  • This is a pretty general question, and you can find good answers in Apple's documentation, e.g. Archives and Serialization Programming Guide and Property List Programming Guide among others. If you have a specific question, please edit the above question to make that clear. Commented Mar 2, 2012 at 19:14
  • @Ole Begemann - I can remember specifically reading a comment like that about plists in "Beginning iOS 5 Development - Exploring the iOS SDK" from Apress, and online in a tutorial show how to dynamically populate a table, I can't remember the link but I do remember that the example showed bugs in it and said something about "scary bugs". Regardless, in defense of those authors, perhaps I misunderstood their statements and they meant you wouldn't use plists for large amounts of data? If plists are valid, then they're exactly what I need. Thanks for the info! Commented Mar 2, 2012 at 19:29
  • @Caleb - yes, the question was meant to be general. Thanks for the links! The "Propery List Programming Guide" answered my question exactly under "When to Use Property Lists". Thanks! Commented Mar 2, 2012 at 19:34

1 Answer 1

3

Some common approaches are:

  • plists - yes, they're a perfectly legitimate data store if your requirements are modest
  • JSON - if that's how your data is coming in from the web
  • SQLite - The embedded relational database system. FMDB is a popular Objective-C interface for this.
  • Core Data - Apple's solution (can use various formats including SQLite as the back-end)
  • [Some custom file format] - any data format you choose to come up with

Realistically, you'll need to read up on the various solutions - they all have pros and cons, and those pros and cons will weigh differently depending on your needs.

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

1 Comment

Thanks pmjordan! This is exactly what I was looking for.

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.