0

我有一个未经处理的异常,它使用最新的 Simperium 库使我的应用程序崩溃。据我所知,我已经设置了所有内容,但是每当它开始尝试同步核心数据更改时,就会发生异常。

这是引发的异常:

2013-07-31 15:02:00:234 Twitter Translator[28336:303] Simperium enqueuing 168 object requests (Tweet)
2013-07-31 15:07:36.446 Twitter Translator[28336:303] -[AppDelegate handleManagedObjectContextChange:]: unrecognized selector sent to instance 0x102609120
2013-07-31 15:07:36.446 Twitter Translator[28336:303] An uncaught exception was raised
2013-07-31 15:07:36.446 Twitter Translator[28336:303] -[AppDelegate   handleManagedObjectContextChange:]: unrecognized selector sent to instance 0x102609120
2013-07-31 15:07:36.449 Twitter Translator[28336:303] (
0   CoreFoundation                      0x00007fff95799b06 __exceptionPreprocess + 198
1   libobjc.A.dylib                     0x00007fff897bb3f0 objc_exception_throw + 43
2   CoreFoundation                      0x00007fff9583040a -[NSObject(NSObject) doesNotRecognizeSelector:] + 186
3   CoreFoundation                      0x00007fff9578802e ___forwarding___ + 414
4   CoreFoundation                      0x00007fff95787e18 _CF_forwarding_prep_0 + 232
5   CoreFoundation                      0x00007fff9574beda _CFXNotificationPost + 2554
6   Foundation                          0x00007fff8c7a27b6 -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
7   CoreData                            0x00007fff93b1b46f -[NSManagedObjectContext _mergeChangesFromDidSaveDictionary:usingObjectIDs:] + 3263
8   Simperium-OSX                       0x00000001001b5251 __34-[SPCoreDataStorage mergeChanges:]_block_invoke + 49
9   libdispatch.dylib                   0x00007fff94d11a2d _dispatch_barrier_sync_f_slow_invoke + 77
10  libdispatch.dylib                   0x00007fff94d0c0b6 _dispatch_client_callout + 8
11  libdispatch.dylib                   0x00007fff94d110c8 _dispatch_main_queue_callback_4CF + 275
12  CoreFoundation                      0x00007fff9573bb4c __CFRunLoopRun + 1644
13  CoreFoundation                      0x00007fff9573b0e2 CFRunLoopRunSpecific + 290
14  HIToolbox                           0x00007fff95247eb4 RunCurrentEventLoopInMode + 209
15  HIToolbox                           0x00007fff95247b94 ReceiveNextEventCommon + 166
16  HIToolbox                           0x00007fff95247ae3 BlockUntilNextEventMatchingListInMode + 62
17  AppKit                              0x00007fff8cc0e533 _DPSNextEvent + 685
18  AppKit                              0x00007fff8cc0ddf2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
19  AppKit                              0x00007fff8cc051a3 -[NSApplication run] + 517
20  AppKit                              0x00007fff8cba9bd6 NSApplicationMain + 869
21  Twitter Translator                  0x0000000100005932 main + 34
22  libdyld.dylib                       0x00007fff8a7a37e1 start + 0
23  ???                                 0x0000000000000003 0x0 + 3
)
2013-07-31 15:07:36.449 Twitter Translator[28336:303] *** Terminating app due to uncaught exception      'NSInvalidArgumentException', reason: '-[AppDelegate handleManagedObjectContextChange:]: unrecognized selector     sent to instance 0x102609120'
*** First throw call stack:
(
0   CoreFoundation                      0x00007fff95799b06 __exceptionPreprocess + 198
1   libobjc.A.dylib                     0x00007fff897bb3f0 objc_exception_throw + 43
2   CoreFoundation                      0x00007fff9583040a -[NSObject(NSObject)     doesNotRecognizeSelector:] + 186
3   CoreFoundation                      0x00007fff9578802e ___forwarding___ + 414
4   CoreFoundation                      0x00007fff95787e18 _CF_forwarding_prep_0 + 232
5   CoreFoundation                      0x00007fff9574beda _CFXNotificationPost + 2554
6   Foundation                          0x00007fff8c7a27b6 -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
7   CoreData                            0x00007fff93b1b46f -[NSManagedObjectContext _mergeChangesFromDidSaveDictionary:usingObjectIDs:] + 3263
8   Simperium-OSX                       0x00000001001b5251 __34-[SPCoreDataStorage mergeChanges:]_block_invoke + 49
9   libdispatch.dylib                   0x00007fff94d11a2d _dispatch_barrier_sync_f_slow_invoke + 77
10  libdispatch.dylib                   0x00007fff94d0c0b6 _dispatch_client_callout + 8
11  libdispatch.dylib                   0x00007fff94d110c8 _dispatch_main_queue_callback_4CF + 275
12  CoreFoundation                      0x00007fff9573bb4c __CFRunLoopRun + 1644
13  CoreFoundation                      0x00007fff9573b0e2 CFRunLoopRunSpecific + 290
14  HIToolbox                           0x00007fff95247eb4 RunCurrentEventLoopInMode + 209
15  HIToolbox                           0x00007fff95247b94 ReceiveNextEventCommon + 166
16  HIToolbox                           0x00007fff95247ae3 BlockUntilNextEventMatchingListInMode + 62
17  AppKit                              0x00007fff8cc0e533 _DPSNextEvent + 685
18  AppKit                              0x00007fff8cc0ddf2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
19  AppKit                              0x00007fff8cc051a3 -[NSApplication run] + 517
20  AppKit                              0x00007fff8cba9bd6 NSApplicationMain + 869
21  Twitter Translator                  0x0000000100005932 main + 34
22  libdyld.dylib                       0x00007fff8a7a37e1 start + 0
23  ???                                 0x0000000000000003 0x0 + 3
 )
libc++abi.dylib: terminate called throwing an exception

我认为发生错误的行是这一行:

     dispatch_sync(dispatch_get_main_queue(), ^{
    [__managedObjectContext mergeChangesFromContextDidSaveNotification:notification];
});

但我不能 100% 确定,因为我的 bug 搜索不是那么好:(

有人有什么想法吗?

谢谢

加雷斯

4

1 回答 1

1

这一行:

2013-07-31 15:07:36.446 Twitter Translator[28336:303] -[AppDelegate   handleManagedObjectContextChange:]: unrecognized selector sent to instance 0x102609120

告诉你你需要知道的一切。您正在尝试将消息发送handleManagedObjectContextChange:到您的应用程序委托,但它没有实现该方法。因此,您需要做的是确定该消息被发送到哪里,并验证它确实被发送到您打算将其发送到的对象。

我意识到这个答案可能有点笼统,但你只提供了一行代码,它并没有告诉我们太多。从堆栈跟踪的外观,确定您正在处理通知的区域;那可能是开始寻找的好地方。

于 2013-07-31T15:58:30.127 回答