My application needs to keep track of which managed object is currently selected. In memory this is easy, but the question is how do I do this when my application exits and restarts.
Can I write the object itself to NSUserDefaults and then retrieve it later (I think this wouldn’t be the same object thou, just a copy) Or can I store the entity id somehow? Or is there another way I’m overlooking?
Just store the NSManagedObjectID. You will likely have to store it as an NSString from the NSURL (
URIRepresentation).Also make sure it is NOT a temporary ID. When the app starts again, load the NSManagedObject from the NSURL from the string you saved.