• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newly inserted objects not retrieved with executeFetchRequest...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newly inserted objects not retrieved with executeFetchRequest...


  • Subject: Re: Newly inserted objects not retrieved with executeFetchRequest...
  • From: Eric MORAND <email@hidden>
  • Date: Tue, 14 Aug 2007 14:09:21 +0200

All right, I found my mistake.

I was not creating the entity description used by the fetch request properly :

entity = [NSEntityDescription entityForName:@"Brand" inManagedObjectContext:managedObjectContext];


Eric.

Le 14 août 07 à 12:50, Eric MORAND a écrit :

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

_______________________________________________

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


References: 
 >Newly inserted objects not retrieved with executeFetchRequest... (From: Eric MORAND <email@hidden>)

  • Prev by Date: Re: Shouldn't be (null) - pathForResource:ofType:inDirectory:forLocalization:
  • Next by Date: Overlay over webView
  • Previous by thread: Newly inserted objects not retrieved with executeFetchRequest...
  • Next by thread: Re: Newly inserted objects not retrieved with executeFetchRequest...
  • Index(es):
    • Date
    • Thread