I am pulling data from an API and then building out my data objects with it. I want to cache this data for the future. I have been storing the string from the api in NSUserDef
Have you noticed the NSCache?
An
NSCache
object is a mutable collection that stores key-value pairs, similar to an NSDictionary object. TheNSCache
class provides a programmatic interface to adding and removing objects and setting eviction policies based on the total cost and number of objects in the cache...
What type of data? If its text/string bases SQLLite would probably be the best.
I'd store the computed/parsed data in either a Core Data store, or in NSData flat files in your application's Documents directory. You're correct that storing that in NSUserDefaults and then re parsing feels a little overkill.
Personally I'm quite fond of the EGOCache classes, I use them quite a lot in my projects:
https://github.com/enormego/EGOCache
The classes are easy to use, I used to have my own classes with a similar design, but these are just more well-rounded, so I decided to stick with them (don't wanna reinvent the wheel).
I vote Core Data
There are many different solutions to this problem and there is no "right" way to do it. A few popular options are:
I would encourage you to read up on all four and see which one works best for you.