I am inserting a new Folder entity into my model object context (MOC), that is a child of the master MOC. Before saving, [[newFolder objectID] isTemporaryId] returns YES. When I save first my MOC and then the master MOC and ask the [[newFolder objectID] isTemporaryId], it again says YES. I expected it to now be a persisted object, and indeed, if I interrogate the SQLite file, it contains the new folder. For the entire time of my running application, it will say YES. Not before I quit and restart, thus loading the object up from the store, does it say NO.
I always thought a NSManagedObject changed from a temporary object to a stored object with no longer a temporary objectID when it was saved. When does an object get a objectID that is not temporary?
Cheers
Nik
Objects in child contexts aren't altered by changes in the parent context until the objects are refreshed. Perhaps refreshing the object after saving the parent context will do the trick.
If that doesn't work, there's always -[NSManagedObjectContext obtainPermanentIDsForObjects:error:]
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With