If you want to persist a custom object to NSUserDefaults
you have two options.
- Encode the object to NSData using an
NSKeyedArchiver
- Create an
NSDictionary
with all of the values you want to persist.
Whether using NSUserDefaults
is the proper approach depends on a few factors. If you just have a one or a few of the objects then that would be fine. If you have a lot, then you may want to look at other options. Perhaps a plist or some other file. Either way, you have the same issue of needed to encode the object using one of the two approaches.