/home/embrenneke

A mostly-fresh start

CoreData Multi-context Error

When using CoreData, it is possible to create a NSManagedObject that lives outside of a NSManagedObjectContext by passing nil as the context arguement to -[NSManagedObject initWithEntity:insertIntoManagedObjectContext:]. If you later decide you want to store the object, just use -[NSManagedObjectContext insertObject:]. This works great, unless you have parent/child contexts. If you use this method and insert into a child context then the new object attributes do not get propagated up to the parent context when saving. The resulting data loss is bad news.

You can get more details and run my sample project on GitHub.