Reputation: 27133
I found a question like mine here, but I don't see any code in the answers.
So the workflow is next:
I create NSManagedObject using next code
[MagicalRecord saveInBackgroundWithBlock:^(NSManagedObjectContext *localContext) {
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"playerID == %@", responseData[@"player"][@"playerID"]];
Player *player = [Player MR_findFirstWithPredicate:predicate];
// on this line above player attributes are still the same at first time created. the player name is Alex if I po player.firstname in console.
// on this line below i import new name for player - Greg.
// so I print player.firstname and the console shows me Greg instead of Alex.
// I think it has to update my value but it does't when I try to print our it in the success block.
[player MR_importValuesForKeysWithObject:responseData];
} completion:^{
// here I want to get my players assuming that there is only one Player just for testing.
NSArray *arr = [Player MR_findAll]; // print arr.count = 1 (just test if i work with one and the same entity)
for (Player *p in arr) {
NSLog(@"%@", p.firstname); // type first name and it is Alex, but has to be Greg, because I have print out it after import line and player first name was Greg. But now it's still Alex. What the problem is?
}
}];
The next step I need to update this NSManagedObject using import feature. How can I do this?
Upvotes: 0
Views: 203
Reputation: 69667
Have a look at this blog post. It explains all the non-code related options to use the import functionality.
Upvotes: 1