I am new to Core Data also RestKit.
Since there are some performance issues, I want to use the concurrency technique in ios5. However, when it combined with RestKit, the crashing problem appeared. Here is my crash code:
[[RKObjectManager sharedManager] getObjectsAtPath: HOT_PATH
parameters: params
success:
^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
NSManagedObjectContext *newContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
newContext.parentContext = [self managedContext];
[newContext performBlock:^{
Rumor *rumorInOtherContext = (Rumor *)[mappingResult.array lastObject];;
Rumor *rumor = (Rumor *)[newContext objectWithID:rumorInOtherContext.objectID];
rumor.updateDate = [NSDate date]; // <- crash at this point.
}];
However, the old version of my code wouldn't crash:
[[RKObjectManager sharedManager] getObjectsAtPath: HOT_PATH
parameters: params
success:
^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
Rumor *rumor = (Rumor *)[mappingResult.array lastObject];;
rumor.updateDate = [NSDate date]; // <- save!
}];
No crash report appeared in console dialog. :(
Is my code correct? Or, are there another approaches to do the same thing?