Reputation: 10245
I am currently reading my coredata like this
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Manuz" inManagedObjectContext:__managedObjectContext];
[fetchRequest setEntity:entity];
NSArray *fetchedObjects = [__managedObjectContext executeFetchRequest:fetchRequest error:nil];
NSManagedObject *myinfo = [NSManagedObject alloc]
for (NSManagedObject *info in fetchedObjects) {
[self startTheParsingProcess:[info valueForKey:@"manu"]];
}
I am having some issues with my for statement, its execuing several time and I am not sure why its doing that.. and come to think of it I don't really need it..
I am hoping there is an alternative solution to this where I just initalize the NSManagedObject and then add it to the method call I do in that for statment...
So I guess something like this
NSManagedObject *info = [[NSManagedObject alloc] init]; //this is obviously wrong..
[self startTheParsingProcess:[info valueForKey:@"manu"]];
any help would be awesome!
Upvotes: 1
Views: 5530
Reputation: 2096
Do not create a NSManagedObject using alloc & init. If you want to create an instance of an entity "Manuz", you would do so by inserting a new Manuz object into the managed object context.
NSManagedObject *newManuz = [NSEntityDescription insertNewObjectForEntityForName:@"Manuz" inManagedObjectContext:context];
Upvotes: 3