OGeek|极客世界-中国程序员成长平台

标题: iphone - 为什么使用 NSMutableDictionary 会导致 NSNotificationCenter 崩溃? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 10:45
标题: iphone - 为什么使用 NSMutableDictionary 会导致 NSNotificationCenter 崩溃?

当使用 NSNotificationCenter 发布通知时,是否有任何理由为什么传入 NSMutableDictionary 而不是 NSDictionary 作为 userInfo 可能会导致崩溃?

- (void)postNotificationNameNSString *)aName objectid)anObject userInfoNSDictionary *)aUserInfo;

我看到以下崩溃日志:

 Exception Type:  SIGSEGV
 Exception Codes: SEGV_ACCERR at 0xffffffffe0000008
0   libobjc.A.dylib                     0x31516fbc objc_msgSend + 16
1   Foundation                          0x3195b50f __57-[NSNotificationCenter addObserver:selector:namebject:]_block_invoke_0 + 19
2   CoreFoundation                      0x37a02577 ___CFXNotificationPost_block_invoke_0 + 71
3   CoreFoundation                      0x3798e0cf _CFXNotificationPost + 1407
4   Foundation                          0x318cf3fb -[NSNotificationCenter postNotificationNamebject:userInfo:] + 67



Best Answer-推荐答案


您的观察者似乎正在使应用程序崩溃。你在 dealloc 之前把它从观察者列表中删除了吗?

关于iphone - 为什么使用 NSMutableDictionary 会导致 NSNotificationCenter 崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8901982/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) Powered by Discuz! X3.4