我正在使用-com.apple.CoreData.ConcurrencyDebug 1
在我的应用中查找任何CoreData并发问题。我遇到过executeFetchRequest
停止的问题:
__block NSArray *results = nil;
[context performBlockAndWait:^{
NSError *error = nil;
results = [context executeFetchRequest:request error:&error];
if (results == nil)
{
[MagicalRecord handleErrors:error];
}
}];
return results;
这是来自MagicalRecord library。我正在运行旧版本,但我认为我的问题是我的代码,而不是MagicalRecord。
它提供的错误是:
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
我正在使用MagicalRecord的默认上下文,我在主线程上。我的谓词中的所有对象也来自默认上下文:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"form == %@ AND id <> 0 AND user == %@", self, user];
我假设在代码中可能会发生其他一些副作用,但我不知道在哪里可以看。要重现我的问题:
tableView:cellForRowAtIndexPath:
,其中包含触发问题的查询。第一次加载表时,查询没有问题。只有在打开新视图并点击取消后。
还有另一组步骤也遇到了这个问题所以我真的不确定是什么导致它。
如何调试副作用?或者,如果问题出在获取请求中,它有什么问题?
是否有任何工具可帮助诊断问题的原因/位置?
任何帮助将不胜感激。谢谢。
以下是完整的回溯:
#0 0x0000000110630a14 in +[NSManagedObjectContext __Multithreading_Violation_AllThatIsLeftToUsIsHonor__] ()
#1 0x0000000110600856 in -[_PFBatchFaultingArray count] ()
#2 0x000000011097d4fe in +[NSSet setWithArray:] ()
#3 0x000000011057b680 in -[NSManagedObjectContext executeFetchRequest:error:] ()
#4 0x000000010b043242 in __67+[NSManagedObject(MagicalRecord) MR_executeFetchRequest:inContext:]_block_invoke at /Users/.../ios/External/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalRecord.m:52
#5 0x00000001105c2127 in developerSubmittedBlockToNSManagedObjectContextPerform ()
#6 0x00000001105c1fee in -[NSManagedObjectContext performBlockAndWait:] ()
#7 0x000000010b04308f in +[NSManagedObject(MagicalRecord) MR_executeFetchRequest:inContext:] at /Users/.../ios/External/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalRecord.m:48
#8 0x000000010b0434fa in +[NSManagedObject(MagicalRecord) MR_executeFetchRequestAndReturnFirstObject:inContext:] at /Users/.../ios/External/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalRecord.m:75
#9 0x000000010b128939 in +[NSManagedObject(MagicalFinders) MR_findFirstWithPredicate:sortedBy:ascending:inContext:] at /Users/.../ios/External/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalFinders.m:183
#10 0x000000010b08c066 in -[FormStructure lastInspectionByUser:] at /Users/.../ios/Sources/Models/Mogenerator/FormStructure.m:29
#11 0x000000010b08c0fe in -[FormStructure hasDraftByUser:] at /Users/.../ios/Sources/Models/Mogenerator/FormStructure.m:34
#12 0x000000010b0d56ac in -[FormsViewController configureCell:atIndexPath:] at /Users/.../ios/Sources/ViewControllers/MainApp/Inspections/FormsViewController.m:193
#13 0x000000010b0d537e in -[FormsViewController tableView:cellForRowAtIndexPath:] at /Users/.../ios/Sources/ViewControllers/MainApp/Inspections/FormsViewController.m:173
#14 0x000000010e6164f4 in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] ()
#15 0x000000010e61662c in -[UITableView _createPreparedCellForGlobalRow:willDisplay:] ()
#16 0x000000010e5ead4f in -[UITableView _updateVisibleCellsNow:isRecursive:] ()
#17 0x000000010e61f686 in -[UITableView _performWithCachedTraitCollection:] ()
#18 0x000000010e606344 in -[UITableView layoutSubviews] ()
#19 0x000000010e573980 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#20 0x000000010e1f9c00 in -[CALayer layoutSublayers] ()
#21 0x000000010e1ee08e in CA::Layer::layout_if_needed(CA::Transaction*) ()
#22 0x000000010e1edf0c in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
#23 0x000000010e1e23c9 in CA::Context::commit_transaction(CA::Transaction*) ()
#24 0x000000010e210086 in CA::Transaction::commit() ()
#25 0x000000010e4e519b in _afterCACommitHandler ()
#26 0x0000000110958c37 in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#27 0x0000000110958ba7 in __CFRunLoopDoObservers ()
#28 0x000000011094e7fb in __CFRunLoopRun ()
#29 0x000000011094e0f8 in CFRunLoopRunSpecific ()
#30 0x0000000113885ad2 in GSEventRunModal ()
#31 0x000000010e4b8f09 in UIApplicationMain ()
#32 0x000000010b07539f in main at /Users/.../ios/Sources/Application/main.m:14
#33 0x000000011149b92d in start ()
#34 0x000000011149b92d in start ()