我有多个崩溃报告指向以下内容:
Thread : Crashed: NSOperationQueue 0x18c7fba0
0 libsystem_platform.dylib 0x38665a36 OSAtomicCompareAndSwap32Barrier + 13
1 libobjc.A.dylib 0x3805694b realizeClass(objc_class*) + 78
2 libobjc.A.dylib 0x38058797 lookUpImpOrForward + 74
3 libobjc.A.dylib 0x3805102b _class_lookupMethodAndLoadCache3 + 34
4 libobjc.A.dylib 0x38050df9 _objc_msgSend_uncached + 24
5 CoreData 0x2da7b5bb -[_NSFaultingMutableSet copyWithZone:] + 238
6 MyApp 0x0027226f -[Zoo getSortedCats] (Zoo.m:63)
7 MyApp 0x00286955 -[BlockExecutionOperation main] (BlockExecutionOperation.m:30)
8 Foundation 0x2e627aa5 -[__NSOperationInternal _start:] + 772
9 Foundation 0x2e6cb96d __NSOQSchedule_f + 60
10 libdispatch.dylib 0x3853e4b7 _dispatch_async_redirect_invoke + 110
11 libdispatch.dylib 0x3853f7d9 _dispatch_root_queue_drain + 224
12 libdispatch.dylib 0x3853f9c5 _dispatch_worker_thread2 + 56
13 libsystem_pthread.dylib 0x38669dff _pthread_wqthread + 298
getSortedCats 方法如下所示:
- (NSArray *)getSortedCats {
NSSet* cats = [self.cats copy]; //this is line 63, where the crash occurs
//do some sorting
return sortedCats;
}
Zoo 是一个带有cats 属性的NSManagedObject 子类:
@property (atomic, retain) NSSet *cats;
那么为什么 self.cats 行会崩溃?这个错误是什么意思?如何避免?它只会偶尔发生一次,并且不可重现。
Best Answer-推荐答案 strong>
核心数据的特殊性。发送 copy 只会返回另一个 NSFaultingMutableSet ,而 Core Data 错误太多,无法做到这一点。
用 [NSSet setWithSet:self.cats] 替换它,你会遇到更少的错误。
关于ios - 核心数据 EXC_BAD_ACCESS KERN_PROTECTION_FAILURE,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/25004654/
|