I'm creating a new NSManagedObject and inserting it into a context with concurrency type private queue (so it runs on a background thread).
Right before I save, I call this:
[appDelegate.backgroundMOC obtainPermanentIDsForObjects:
[NSArray arrayWithObject:newObject] error:&error];
Then I save:
[appDelegate.backgroundMOC save:&err];
However, I get a EXC_BAD_ACCESS crash. Looking at the stacktrace, I see:
0 semaphore_wait_trap
7-[NSManagedObjectContentSave:]
I'm guessing the problematic line is the semaphore_wait_trap
, but I'm not sure how that's caused.
If I comment out the line obtainPermanentIDsForObjects
, the problem goes away.
Any ideas?