iOS10 Open Beta - iOS Core Data 保存时崩溃
<p><p>我假设在这里发布测试版 iOS10 问题是可以的,因为它是一个公开测试版。苹果论坛在 Stackoverflow 上获得的帮助远不及。</p>
<p>自从更新到 iOS10 后,我们的用户在 CoreData 中保存 managedObjectContext 时经常遇到崩溃。</p>
<p>这是自 iOS 5 以来完美运行的东西。</p>
<p>它只发生在 64 位版本的 iOS10 上。 32位版本运行良好。</p>
<p>这是我的简单保存代码片段:</p>
<pre><code> [self.managedObjectContext performBlockAndWait:^{
NSError *error;
if (!)
{
NSLog(@"\n\nerror in save 1 %@\n\n", error);
}
}];
[self.managedObjectContext performBlock:^{
NSError *error;
if (!)
{
NSLog(@"\n\nerror in save 2 %@\n\n", error);
}
}];
</code></pre>
<p>(上面的 NSLog 没有任何报告,因为它在模拟器中工作)。</p>
<p>这仅在 64 位设备上失败。我无法在模拟器上复制。由于我唯一的 64 位设备无法正确连接到 Xcode,我也无法在设备上进行调试。所以我有点卡住了。</p>
<p>以下是用户报告的示例堆栈跟踪:</p>
<pre><code> Incident Identifier: 7A8DD23B-48A2-4ABF-88E7-67F1E6CDA8D5
CrashReporter Key: 5454e7c7b99a94cd75b6adfa8334bbdf10b859eb
Hardware Model: iPhone8,1
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd
Date/Time: 2016-07-20 22:23:00.1429 -0400
Launch Time: 2016-07-20 22:21:30.6058 -0400
OS Version: iPhone OS 10.0 (14A5309d)
Report Version: 104
Exception Type:EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000985e4beb8
Triggered by Thread:0
Thread 0 name:
Thread 0 Crashed:
0 libobjc.A.dylib 0x00000001850e6eb0 objc_msgSend + 16
1 CoreFoundation 0x0000000185a76740 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20 (CFNotificationCenter.c:650)
2 CoreFoundation 0x0000000185a75e44 _CFXRegistrationPost + 400 (CFNotificationCenter.c:164)
3 CoreFoundation 0x0000000185a75bc0 ___CFXNotificationPost_block_invoke + 60 (CFNotificationCenter.c:1031)
4 CoreFoundation 0x0000000185ae40cc - + 1504 (CFXNotificationRegistrar.m:163)
5 CoreFoundation 0x00000001859b9484 _CFXNotificationPost + 376 (CFNotificationCenter.c:1028)
6 Foundation 0x000000018644e9dc - + 68 (NSNotification.m:482)
7 CoreData 0x0000000187e1dbf4 - + 880 (NSManagedObjectContext.m:7381)
8 CoreData 0x0000000187dabb4c - + 2156 (NSManagedObjectContext.m:5827)
9 CoreData 0x0000000187d98570 - + 3440 (NSManagedObjectContext.m:1532)
10App 0x000000010008db34 __29-_block_invoke227 + 52 (RPSAppDelegate.m:338)
11CoreData 0x0000000187e17c68 developerSubmittedBlockToNSManagedObjectContextPerform + 168 (NSManagedObjectContext.m:3529)
12libdispatch.dylib 0x0000000185525784 _dispatch_client_callout + 16 (object.m:455)
13libdispatch.dylib 0x000000018552a330 _dispatch_main_queue_callback_4CF + 1000 (inline_internal.h:2421)
14CoreFoundation 0x0000000185a8a0cc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 (CFRunLoop.c:1793)
15CoreFoundation 0x0000000185a87cb8 __CFRunLoopRun + 1660 (CFRunLoop.c:3004)
16CoreFoundation 0x00000001859b78d8 CFRunLoopRunSpecific + 444 (CFRunLoop.c:3113)
17GraphicsServices 0x00000001873be198 GSEventRunModal + 180 (GSEvent.c:2245)
18UIKit 0x000000018b9617c8 - + 664 (UIApplication.m:2651)
19UIKit 0x000000018b95c534 UIApplicationMain + 208 (UIApplication.m:4088)
20App 0x000000010008c138 main + 152 (main.m:27)
21libdyld.dylib 0x00000001855585b8 start + 4
</code></pre>
<p>感谢您的任何想法。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您将 <code>_privateWriterContext</code> 保存在 <code>managedObjectContext</code> 的 block 调用中。这是不允许的。它之前有效的事实是“误报”。 </p>
<p>相反,您应该始终只在创建 block 的同一上下文中使用。</p></p>
<p style="font-size: 20px;">关于iOS10 Open Beta - iOS Core Data 保存时崩溃,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/38806916/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/38806916/
</a>
</p>
页:
[1]