当设备和模拟器未连接到 Xcode 时,Core Data 崩溃

发布于 2024-12-19 14:15:19 字数 1342 浏览 4 评论 0原文

当连接到 Xcode 时,我的应用程序可以在设备和模拟器中运行。否则它会在此时崩溃(在没有 Xcode 的情况下运行时在两个设备/模拟器上)。一定是调试器让它保持活动状态或者什么的。我认为崩溃来自:

CDObject * cdObject = [NSEntityDescription insertNewObjectForEntityForName:@"CDObject" inManagedObjectContext:self.moc];

我在程序的其他地方使用了核心数据,并且它工作正常。 我已经通过 NSLog 语句验证 self.moc 不为零。这是崩溃报告的一部分..

    Date/Time:       2011-12-06 10:19:39.146 -0500
OS Version:      iPhone OS 5.0 (9A334)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x3d6936a8
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib                 0x362b6fca objc_msgSend + 30
1   CoreFoundation                  0x374276ea CFDictionarySetValue + 102
2   CoreData                        0x317082ec _PFCMT_SetValue + 852
3   CoreData                        0x31769b90 -[NSManagedObjectContext(_NSInternalAdditions) _insertObjectWithGlobalID:globalID:] + 60
4   CoreData                        0x31760aba -[NSManagedObjectContext insertObject:] + 134
5   CoreData                        0x31707d56 -[NSManagedObject initWithEntity:insertIntoManagedObjectContext:] + 538
6   CoreData                        0x3173f5ce +[NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext:] + 174

My app runs on both the device and in simulator when connected to Xcode. Other wise it crashes at this point (On both device / simulator when run without Xcode). Must be the debugger keeping it alive or something. I think the crash is coming from:

CDObject * cdObject = [NSEntityDescription insertNewObjectForEntityForName:@"CDObject" inManagedObjectContext:self.moc];

I use Core Data else where in the program and it is working fine.
I've verified that the self.moc is not nil through NSLog statements. Here is part of the crash report..

    Date/Time:       2011-12-06 10:19:39.146 -0500
OS Version:      iPhone OS 5.0 (9A334)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x3d6936a8
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib                 0x362b6fca objc_msgSend + 30
1   CoreFoundation                  0x374276ea CFDictionarySetValue + 102
2   CoreData                        0x317082ec _PFCMT_SetValue + 852
3   CoreData                        0x31769b90 -[NSManagedObjectContext(_NSInternalAdditions) _insertObjectWithGlobalID:globalID:] + 60
4   CoreData                        0x31760aba -[NSManagedObjectContext insertObject:] + 134
5   CoreData                        0x31707d56 -[NSManagedObject initWithEntity:insertIntoManagedObjectContext:] + 538
6   CoreData                        0x3173f5ce +[NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext:] + 174

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文