简体   繁体   English

是什么导致此崩溃?

[英]What can be causing this crash?

I've recently had a crash concerning a selector not being found when a notification was posted using NSNotificationCenter. 我最近在使用NSNotificationCenter发布通知时遇到崩溃,原因是找不到选择器。 What can be causing this error? 是什么导致此错误?

I've noticed that there was no user code being called after the notification was posted, so that doesn't seem to be a problem on the receiving side of the notification. 我注意到通知发布后没有调用用户代码,因此在通知的接收方似乎没有问题。 However, what could cause NSNotificationCenter to crash? 但是,什么原因可能导致NSNotificationCenter崩溃?

Here's the stack trace of the call: 这是调用的堆栈跟踪:

0   libSystem.B.dylib               0x00078ac8 __kill + 8
1   libSystem.B.dylib               0x00078ab8 kill + 4
2   libSystem.B.dylib               0x00078aaa raise + 10
3   libSystem.B.dylib               0x0008d03a abort + 50
4   libstdc++.6.dylib               0x00044a20 __gnu_cxx::__verbose_terminate_handler() + 376
5   libobjc.A.dylib                 0x00005958 _objc_terminate + 104
6   libstdc++.6.dylib               0x00042df2 __cxxabiv1::__terminate(void (*)()) + 46
7   libstdc++.6.dylib               0x00042e46 std::terminate() + 10
8   libstdc++.6.dylib               0x00042f16 __cxa_throw + 78
9   libobjc.A.dylib                 0x00004838 objc_exception_throw + 64
10  CoreFoundation                  0x000a167c -[NSObject(NSObject) doesNotRecognizeSelector:] + 96
11  CoreFoundation                  0x000491d2 ___forwarding___ + 502
12  CoreFoundation                  0x00048f88 _CF_forwarding_prep_0 + 40
13  Foundation                      0x000146ac _nsnote_callback + 136
14  CoreFoundation                  0x0002670c __CFXNotificationPost_old + 396
15  CoreFoundation                  0x000263ac _CFXNotificationPostNotification + 112
16  Foundation                      0x0000b014 -[NSNotificationCenter postNotification:] + 132
17  [My Application]                0x000a5ad2 -[PortfolioUpdateOperation main] (PortfolioUpdateOperation.m:37)
18  Foundation                      0x0000e9e8 -[__NSOperationInternal start] + 652
19  Foundation                      0x0000e74c -[NSOperation start] + 16
20  Foundation                      0x00023574 ____startOperations_block_invoke_2 + 40
21  libSystem.B.dylib               0x000d597c _dispatch_call_block_and_release + 12
22  libSystem.B.dylib               0x000d675c _dispatch_worker_thread2 + 120
23  libSystem.B.dylib               0x0007a67a _pthread_wqthread + 258
24  libSystem.B.dylib               0x00073190 start_wqthread + 0

Looks like you added an object as an observer that doesn't respond to the selector you provided. 看起来您添加了一个对象作为观察者,该对象不响应您提供的选择器。 Make sure your notification method accepts one argument of type NSNotification 确保您的通知方法接受一个NSNotification类型的参数

Most likely NSNotificationCenter is trying to notify an object instance that no longer exists. NSNotificationCenter最有可能尝试通知对象实例不再存在。

In other words, an object was deallocated without removing itself as a NSNotificationCenter observer. 换句话说,对象被释放而没有作为NSNotificationCenter观察者移除。 Check your code for cases when an object adds itself as a NSNotificationCenter observer but fails to remove itself from NSNotificationCenter. 检查您的代码,以了解对象是否将自己添加为NSNotificationCenter观察者,但无法将其从NSNotificationCenter中删除。

也许先检查一下respondsToSelector然后再记录对象的类名等,这样可以进一步帮助您?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM