Note that there are some explanatory texts on larger screens.

plurals
  1. POproblem with coredata
    primarykey
    data
    text
    <p>I have a problem that whenever I'm inserting data using coredata, everything's going fine. But while retrieving, I'm getting the same object all the time retrieved. I'm inserting objects of actors with multiple attribues like id,name,address etc. in add method, I can see everything getting inserted(which actually I'm retrieving from an xml file). my set methods are like:=</p> <pre><code>[poi setActorCity:[NSString stringWithFormat:@"%@",[poi1 objectAtIndex:j]]]; </code></pre> <p>where, poi is an object of my <code>managedObjectClass POI1 </code>. Are those a problem? &amp; j index is simply for keeping track of xml values from poi1 array. Please help... </p> <ul> <li>(void)addEvent {</li> </ul> <p>[actorsArray removeAllObjects];</p> <p>NSEntityDescription *entity1 = [NSEntityDescription entityForName:@"POI1" inManagedObjectContext:self.managedObjectContext]; </p> <p>POI1 *poi = (POI1 *)[NSEntityDescription insertNewObjectForEntityForName:@"POI1" inManagedObjectContext:managedObjectContext];</p> <pre><code>for(NSInteger i=0;i&lt;[Actors count];i++) { NSMutableArray *poi1=[[NSMutableArray alloc]init]; poi1=[Actors objectAtIndex:i]; for(int j=0;j&lt;[poi1 count];j++) { if(j==1) { [poi setActorName:[NSString stringWithFormat:@"%@",[poi1 objectAtIndex:j]]]; } //Like this it inserts for every attribute } [actorsArray insertObject:poi atIndex:i]; [poi release]; } [self saveAction]; //saving the managedObjectContext </code></pre> <p>}</p> <p>This' my fetch method...</p> <p>-(void)fetchResult {</p> <pre><code>NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; </code></pre> <p>NSEntityDescription *entity1 = [NSEntityDescription entityForName:@"POI1" inManagedObjectContext:self.managedObjectContext];</p> <p>[fetchRequest setEntity:entity1];</p> <pre><code>NSArray *items = [self.managedObjectContext executeFetchRequest:fetchRequest error:&amp;error]; for(NSInteger k=0;k&lt;[items count];k++) { POI1 *_poi=[[POI1 alloc]init]; _poi = [items objectAtIndex:k]; NSString *str=[NSString stringWithFormat:@"%@",[_poi actorName]]; //This' for testing... Shows me same name every time.., } [fetchRequest release]; </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload