Newly inserted objects not retrieved with executeFetchRequest...
Newly inserted objects not retrieved with executeFetchRequest...
- Subject: Newly inserted objects not retrieved with executeFetchRequest...
- From: Eric MORAND <email@hidden>
- Date: Tue, 14 Aug 2007 12:50:19 +0200
Hi guys,
Is it normal that newly inserted objects do not appear in the
results returned by exceuteFetchRequest ?
Here is the code I'm using :
- (void)insertNewBrandWithName:(NSString *) newBrandName
{
Brand * selectedBrand = nil;
selectedBrand = [[[Brand alloc] initWithEntity:[NSEntityDescription
entityForName:@"Brand" inManagedObjectContext:managedObjectContext]
insertIntoManagedObjectContext:managedObjectContext] autorelease];
NSLog (@" insertedObjects = %@", [managedObjectContext
insertedObjects]);
// TEST
NSFetchRequest * fetchRequest = [[[NSFetchRequest alloc] init]
autorelease];
NSEntityDescription * entity = [[[NSEntityDescription alloc] init]
autorelease];
NSArray * results = nil;
[entity setName:@"Brand"];
[fetchRequest setEntity:entity];
results = [managedObjectContext executeFetchRequest:fetchRequest
error:nil];
NSLog (@" results = %@", results);
}
The first NSLog call confirms that me newly created Brand has
correctly been inserted in the MOC. But the second NSLog call
confirms that it is not present in the context : the array returned
by executeFetchRequest contains all the Brands but the one newly
inserted.
Is there something I am doing wrong here or is there a logic that I
did not understood about MOC ?
Thanks,
Eric.
_______________________________________________
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