re: My FetchRequest is not aware of changes I made
re: My FetchRequest is not aware of changes I made
- Subject: re: My FetchRequest is not aware of changes I made
- From: Ben Trumbull <email@hidden>
- Date: Wed, 13 Feb 2008 14:29:28 -0800
At 3:52 AM -0800 2/12/08, email@hidden wrote:
NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
[request setEntity:[NSEntityDescription entityForName:@"Foo"
inManagedObjectContext:managedObjectContext]];
[request setPredicate:[NSPredicate predicateWithFormat:@"ALL
bars.isHappy = YES"]];
You're searching for Foo, but those objects are all unmodified.
Why doesn't the fetch request finds 0 Foos? Why isn't the fetch
request aware of the changes just made when the GUI is?
The additional filtering of pending/unsaved changes is limited to the
entity you fetch against (and its subentities). In this case, any
modified, inserted, or deleted (pending) Foo would display the
behavior you want.
The only thing that makes it work is to save the context after doing
the changes, but I don't want to save at that point.
You can evaluate the request against the Bar entity, and pull out the
Foo across the inverse. Or you can union the results from the fetch
request with your own in memory filtering of all the registered
objects in the MOC. Or you can make this code call
-willChangeValueForKey: on Foo to dirty them (but this will also
cause them to get saved)
--
-Ben
_______________________________________________
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:
This email sent to email@hidden