Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Threads and Core Data, bindings results in view corruption



I would think this is the normal typical case, but can't figure it out.
The UI should run on one thread, another thread should be used for time
consuming updates/generation of an object tree maintained using Core Data. I
have a NSOutlineView (via NSTreeController subclass) which displays the
object tree from Core data.

I can not figure out how to make this thread safe. I periodically get random
data showing up in the outline view while the core data object tree is being
updated.

I've tried locking the managedObjectContext when I make additions or changes
to the object tree, but I still get erroneous data showing up in the view.

I don't understand how NSTreeController and bindings are interacting with
Core data to extract the data while I'm populating it.

Any suggestions greatly appreciated.

I've been reading and rereading the Core Data programming guide and
Threading programming guide to no avail.

The Core data programming guide says its best to maintain a separate
managedObjectContext per thread. But this appears to require the data to be
written to persistent store to make it work (file). That not reasonable in
my case where I'm adding many objects to an object tree. It takes a
significant amount to time to write it out, negating the benefit of trying
to make the UI seem responsive.

I'm running Leopard.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.