我在TestFlight中有一个应用程序,它会在第一次核心数据保存时崩溃。我自己从来没有能够重新创建这个问题,但是多个用户多次发生这种情况。我从我们的服务器获取一组分类作为JSON,然后将结果保存到核心数据,如下所示:
[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
[self createRestrictions:restrictions inContext:localContext];
} completion:^(BOOL success, NSError *error) {
if(success){
dispatch_async(dispatch_get_main_queue(), ^(void) {
DLog(@"got and saved all restrictions");
if(complete){
complete(YES);
}
});
}else{
TFLog(@"error saving restrictions: %@", error);
if(failure){
failure(@"Error saving restrictions");
}
}
}];
-(void)createRestrictions:(NSArray *)restrictions
inContext:(NSManagedObjectContext *)context
{
for(NSDictionary *_restriction in restrictions){
Restriction *restriction = [Restriction MR_findFirstByAttribute:@"tid"
withValue:[NSNumber numberWithInt:[_restriction[@"tid"] intValue]]
inContext:context];
if(!restriction){
restriction = [Restriction MR_createInContext:context];
restriction.tid = [NSNumber numberWithInt:[_restriction[@"tid"] intValue]];
}
...
}
}
以下是TestFlight
的崩溃日志的屏幕截图