Open ole opened 10 years ago
@ole Don't you want performBlockAndWait
? Otherwise, this block is queued, then the enclosing function returns and ARC releases your persistent store coordinator, before this block gets a chance to execute.
@peymano Thanks for the suggestion. I tried (and @richardbuckle did too) but it doesn't change the outcome. Anyway, it shouldn't matter. The persistent store coordinator is retained by the managed object context and the context lives at least until the end of the block's lifetime.
When
-com.apple.CoreData.ConcurrencyDebug 1
is activated, this code:fails with a multithreading violation assertion in the line
let didSave = backgroundContext!.save(&potentialSaveError)
. I don't understand why since I have wrapped all access to the background context in aperformBlock
call.@richardbuckle I would appreciate any input you have. Does it fail on your machine, too?