Re: CoreData: NSManagedContext not updating NSArrayController in UI
Re: CoreData: NSManagedContext not updating NSArrayController in UI
- Subject: Re: CoreData: NSManagedContext not updating NSArrayController in UI
- From: mmalcolm crawford <email@hidden>
- Date: Mon, 21 Nov 2005 13:36:21 -0800
On Nov 21, 2005, at 12:59 AM, Marc Monguio wrote:
I'm trying to update the main moc (NsManagedObjectcontext *) with
the new values inserted from another moc in another thread. I want
an NSArrayController to show the moc's new registered values in the
interface
The "BackgroundFetching" example in <file:///Developer/Examples/
CoreData/> shows how to do this.
- (void)updateManagedObjectContext:(NSNotification *)aNotification;
{
NSManagedObject *insertedObject;
NSSet *registeredObjects = [moc registeredObjects];
NSSet *insertedObjects = [[aNotification userInfo]
objectForKey:NSInsertedObjectsKey];
while ((insertedObject = [enumerator nextObject]) != nil) {
//this should register the insertedObject from the other thread to
the main moc
staleObject = [moc objectWithID:[insertedObject objectID]];
//to be sure I refresh it, it doesn't work either...
[moc refreshObject:staleObject mergeChanges:NO];
//to be sure I save, it doesn't work either...
[moc save:&error];
It's not clear why you would want to refresh or save an object you've
just retrieved?
So what I'm doing is populate the main moc that is also used in the
NSArrayController. But the NSArrayController doesn't show the new
inserted values in the UI unless I ask for a fetch:
- (void)updateManagedObjectContext:(NSNotification *)aNotification;
{
[myArrayController fetch:self];
}
Have you set the "Automatically prepares content" switch for the
controller?
<http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/
Articles/cdTroubleshooting.html#//apple_ref/doc/uid/TP40002320-
DontLinkElementID_69>
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden