I'm using a parent context on a private queue and a child (main) context on the 
main queue.  I do everything in the UI with the child context and save the 
results as the view disappears.

I had a bug where the first time I ran the app, I was able to add objects and 
save them in the child context.  When the app would terminate or enter the 
background, I would save the child context (because that is the way my old code 
was setup).  The next time I ran the app, it would crash while loading the 
initial table view from a fetched-results-controller (FRC).  The crash was due 
to getting an object from the controller using -objectWithIndex:.  The FRC says 
it has one object but when I go to access it, I get an exception due to an 
invalid index (no data)!

As soon as I replaced the final save of the child context, during transition to 
background or termination, with a save of the parent context, this problem went 
away.  My theory is that the save to the child context updates the indexes but 
the data never actually hits the disk since I never executed a save on the 
master context.

I think I have another problem, though I haven't had it blow up yet, and that 
is that I'm executing the save of the parent context from my main thread when 
the app is transitioning to the background or terminating.  Remembering that 
this parent context is associated with a private queue I wonder if this is ok?  
I seem to recall Marcus Zarra saying everything being executed on a private 
queue MOC has to be executed using the -performBlock: or -performBlockAndWait: 
calls.

-Michael
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to