我一直在MagicalRecord的代码中从我的用户那里得到Segmentation fault:
-[NSManagedObject(MagicalRecord_DataImport) MR_addObject:forRelationship:] in NSManagedObject+MagicalDataImport.m on Line 144
我不知道如何在我的代码中复制或修复问题。这就是我正在做的事情:
- (void)saveResources:(NSArray*)resources {
NSDictionary *attr = resources[0];
// needs to update the id of _this_ object
[self.item importValuesForKeysWithObject:attr];
[[self.item managedObjectContext] MR_saveToPersistentStoreAndWait];
}
导致问题的是importValuesForKeysWithObject
方法。下载完成后调用此方法(AFJSONRequestOperation
)。
每当我在本地测试它时,我都没有问题,它只会偶尔发生在我的用户身上。那么我该如何找出导致分段错误的原因并进行修复呢?
答案 0 :(得分:0)
我的猜测是你的变量attr包含nil元素,当importValuesForKeysWithObject
正在处理它时会导致段错误。在传递它之前,我会首先对attr进行一些测试。