ios - 核心数据 EXC_BAD_ACCESS KERN_PROTECTION_FAILURE
<p><p>我有多个崩溃报告指向以下内容:</p>
<pre><code>Thread : Crashed: NSOperationQueue 0x18c7fba0
0libsystem_platform.dylib 0x38665a36 OSAtomicCompareAndSwap32Barrier + 13
1libobjc.A.dylib 0x3805694b realizeClass(objc_class*) + 78
2libobjc.A.dylib 0x38058797 lookUpImpOrForward + 74
3libobjc.A.dylib 0x3805102b _class_lookupMethodAndLoadCache3 + 34
4libobjc.A.dylib 0x38050df9 _objc_msgSend_uncached + 24
5CoreData 0x2da7b5bb - + 238
6MyApp 0x0027226f - (Zoo.m:63)
7MyApp 0x00286955 - (BlockExecutionOperation.m:30)
8Foundation 0x2e627aa5 - + 772
9Foundation 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
</code></pre>
<p>getSortedCats 方法如下所示:</p>
<pre><code>- (NSArray *)getSortedCats {
NSSet* cats = ; //this is line 63, where the crash occurs
//do some sorting
return sortedCats;
}
</code></pre>
<p>Zoo 是一个带有cats 属性的NSManagedObject 子类:</p>
<pre><code>@property (atomic, retain) NSSet *cats;
</code></pre>
<p>那么为什么 self.cats 行会崩溃?这个错误是什么意思?如何避免?它只会偶尔发生一次,并且不可重现。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>核心数据的特殊性。发送 <code>copy</code> 只会返回另一个 <code>NSFaultingMutableSet</code>,而 Core Data 错误太多,无法做到这一点。 </p>
<p>用 <code></code> 替换它,你会遇到更少的错误。 </p></p>
<p style="font-size: 20px;">关于ios - 核心数据 EXC_BAD_ACCESS KERN_PROTECTION_FAILURE,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/25004654/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/25004654/
</a>
</p>
页:
[1]