2

So I have been doing lots of reading and found out NSCache is not persistent which is a slight problem for what I need to do. I have heard that I will need to use Core data instead... but I don't have any experience with core data so am wondering if its the only solution for persistent data.

The app will allow the user to search through a catalog, by typing in a search parameter in the code and select a distributor for their search parameter. What I want to do when the app loads is download the list of distributors and save them to a "cache" the will be persistent (till when the header I will make at some point changes and demands the app to update the cache), so that if the user turns the app of or the phone next time then open it the manufacture.

Now that I'm getting abit deeper into my app I'm getting abit lost in things for instance how would setting up a cache work with regards to NSURLConnection.

Any suggestions or code examples would be greatly appreciated..

tinhead
  • 385
  • 2
  • 10
  • 29

2 Answers2

2

This previous answer of mine might help you decide.

To sum it up:

  1. If your data is small, static and low-complexity, use a collection class and write it to disk using the built-in class methods
  2. If the data is static, low-complexity but large, SQL may be a good solution especially if you already know it.
  3. If the data is dynamic and complex regardless of size, then Core Data is your best choice.

Viewed purely from the technical perspective, Core Data is always the best choice for iOS/MacOS API apps. Core Data is not just a persistence API, it is an API for creating the model layer of the Model-View-Controller design paradigm that the Apple API uses. It not only persist the data, but models it, validates its and provides an easy interface to the rest of the API.

If your going to be writing iOS apps, you need to eventually learn Core Data. However, it does have a learning curve and you should pick the method right now that will let you ship a usable app.

Community
  • 1
  • 1
TechZen
  • 64,370
  • 15
  • 118
  • 145
  • Hrmm, yea the data will likely change several time ever month or two. So its almost static but officially its dynamic.I am thinking core data is going to be important at some stage so I may as well start using it now and learning it. Thanks for your answer. Am going to ready your other answer now :) – tinhead May 16 '11 at 01:59
  • Two questions, first what dose "object graph management system" mean and secondly your graph suggests plist's are a option? is this correct? – tinhead May 16 '11 at 02:23
  • An object graph is a group of connected objects where the connections are as important as the data in the object attributes. Plist are created automatically when you save an NSArray, NSDictionary etc. You can create very complex structures of nested arrays and dictionaries and just write it all out to file with one command. – TechZen May 16 '11 at 02:34
1

You can also check out sqlite. Here's another question that discusses getting started with sqlite on the phone: Where's the best SQLite 3 tutorial for iPhone-SDK?

The advantage to sqlite is that it is fairly easy to pick up. The downside is that you have to write queries for everything, and that can be a pain. It doesn't save objects, just data, numbers or text.

Community
  • 1
  • 1
Adrian Sarli
  • 2,286
  • 3
  • 20
  • 31
  • So is that a good option to read in the continence of the manufacture list on the server into my own sql database on the phone? Once the data is in there what is the best thing to do with it each time the app loads? do i load that data then into a cache or something else? – tinhead May 16 '11 at 01:26
  • Once the data is in the sqlite database, each time the app opens it checks for updated data, and if there is some, it downloads it and re-populates the database. Then you can make objects out of the data in the database and use them in your app. – Adrian Sarli May 16 '11 at 01:28
  • okay cool, sounds like a nice solution. What sort of check is done for the update? can I set it to say something like a version number I place in a header request or will it do it all automatically? thanks for the help btw will start getting into these links you sent me. I want to make sure I have my head around this stuff completely before I continue. – tinhead May 16 '11 at 01:34