Re: [CoreData] Background Insertion
Re: [CoreData] Background Insertion
- Subject: Re: [CoreData] Background Insertion
- From: Andrew Kimpton <email@hidden>
- Date: Tue, 5 Jun 2007 15:56:51 -0400
On Jun 5, 2007, at 3:15 PM, Marcus S. Zarra wrote:
This is very odd. I did get it to work by changing your dataSaved:
method to:
- (void)dataSaved:(NSSet*)list
{
if ( usesPrepareContent )
[listController prepareContent];
else
{
NSEnumerator* enumerator = [list objectEnumerator];
NSManagedObjectID* objectid;
while ( (objectid = [enumerator nextObject]) != nil )
{
NSManagedObject* object = [managedObjectContext
objectWithID:objectid];
[managedObjectContext refreshObject:object mergeChanges:NO];
}
[listController prepareContent]; //MSZ Added
}
[list release];
}
As to why this is necessary, I am stumped. It should be picking it
up automatically. This solves it but I am not sure if you want to
do something like this. Although having your delegate broadcast a
"data updated" notification might solve the issue.
When I do background processing, I close all of the windows that
display the data and bring up a progress dialog which is modal. So
I am probably not seeing this behavior because the controller
reload when the windows get presented. Now I will have to go back
into my code and see if I can duplicate this behavior and join you
in a radar filing...
I've solved part of my problem - but as per the above the problems
are not completely solved.
Part 1 of my problem is that I was called [managedObjectContext
objectRegisteredWithID] NOT [managedObjectContext objectWithID] using
the second message gives non-null pointers for objects in the
'inserted set' - which is more like what I was expecting. On
reflection this makes sense - I guess objectRegisteredWithID only
works for a subset of objects 'previously registered' ? i.e. Objects
that have previously faulted ? For newly inserted objects (inserted
into a second different managed object context) this would not be
true ? They would not have faulted and thus not be registered in the
managed object context of the main thread ?
Cool.... now I get valid objects - and the exact same symptoms
described above. At least I think it's the same I'm not able to so
easily verify that sending prepareContent fixes the problem - I have
a number of controllers and I don't generally have them registered
with any window controller that's also receiving the completed save
notification. I'll try that next...
It really does seem however that the Object Controllers should be
notified of new objects that are present in the managed object
context ? Again if I insert the object directly in to the main
thread's managed object context I don't need to do anything - however
if I use objectForID to fault them into the context the controllers
don't seem to notice.
Andrew 8-)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden