在多功能调用的反向传播中遇到问题。
例如,
NSError *error = nil;
EMSPlanFolder *planner = [[EMSPlanFolder sharedPlanBuilder] buildPlanFromParsePlan:plan withError:&error];
if (error) {
//error
}
接下来,它进入函数:
- (EMSPlanFolder*)buildPlanFromParsePlan:(EMParsedPlan*)parsedPlan withError:(NSError *__autoreleasing*)err
{
....
....
[self deserializePlan:parsedPlan forPlan:newPlanFolder allowingNoEndDate:NO withError:err];
if(err && *err) {
[newPlanFolder.managedObjectContext performBlockAndWait:^{
[EMSPlanFolder deletePlan:newPlanFolder];
}];
return nil;
}
return newPlanFolder;
}
接下来,它到达:
- (void)deserializePlan:(NSArray*)planElements forPlan:(LMSPlanFolder*)planFolder allowingNoEndDate:(BOOL)allowNoEndDate withError:(NSError *__autoreleasing*)err {
....
....
if(err) {
*err = [NSError errorWithDomain:@"Application" code:-1 userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Plan was not found."]}];
}
return;
}
问题是,当它向第一个代码片段进行反向传播时,会导致崩溃。对此有什么建议吗?
NSManagedObjectContext
的performBlockAndWait:
中? - clemens