Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persisting data objects on the iphone

I was wondering what your thoughts were on persisting objects (NSDictionarys and NSMutableArrays of Objects) on the iPhone?

I've gone through a couple of options in my head:

1.) We persist using NSUserDefaults, this method seems the easiest and I sort of want to just go ahead and use this. The Data I want to store would only maybe be a few kilobytes of objects.

2.) Using NSKeyedArchiver (the exact name alludes me atm) to archive/serialize and then just puting that into a SQLITe database. but the problem with that is:

I need the data, when it's changed on the phone, to automatically be saved. NSUserDefaults has a synchronization method for this, but for method #2 I'd have to re-archive the entire array of objects, and then store it back into the database. This seems like a lot of work.

3.) forgot about this I've heard things about CoreData being able to handle this sort of thing, but I'm not sure if I understand exactly.

So what do you guys think? Do you have any other suggestions?

like image 865
kodai Avatar asked Aug 09 '26 06:08

kodai


1 Answers

I recommend going the extra mile and use Core Data.

  • First you will learn a new thing, a good thing.
  • But further more your app will start up faster and handle data much more fluently as data is fetched in chunks rather requiring reading the whole dataset.

...don't be afraid, just try it. Start small and keep going.

like image 64
epatel Avatar answered Aug 11 '26 21:08

epatel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!