iphone – 调试NSNotificationCenter问题的方法?

栏目: IOS · 发布时间: 6年前

内容简介:翻译自:https://stackoverflow.com/questions/2123846/methods-to-debug-nsnotificationcenter-issues

我发布的通知中有一些问题:

[[NSNotificationCenter defaultCenter] postNotificationName:@"MobileProviderChanged" 
                                                    object:self.selectedProviderID];

不被我的观察者困住:

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(onProviderChanged:) 
                                             name:@"MobileProviderChanged"
                                           object:nil];

完全相同的观察者在不同的ViewController中正常工作.

有关调试此方法的任何提示,以查看实际发布到defaultCenter的消息是什么?

谢谢.

The more I research this issue I  wonder if my problem is that the  sending viewcontroller is on a  different thread than the observing  viewcontroller.

不正确的多线程几乎肯定是您的问题的根源.但是,仍应发送和接收通知.

具体而言,将收到有关发送的任何线程的通知.既然你提到你正在使用视图控制器来响应通知,很可能你在非主要线程上做了一些UIKit不满意的事情.

翻译自:https://stackoverflow.com/questions/2123846/methods-to-debug-nsnotificationcenter-issues


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Learning Python, 5th Edition

Learning Python, 5th Edition

Mark Lutz / O'Reilly Media / 2013-7-6 / USD 64.99

If you want to write efficient, high-quality code that's easily integrated with other languages and tools, this hands-on book will help you be productive with Python quickly. Learning Python, Fifth Ed......一起来看看 《Learning Python, 5th Edition》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

URL 编码/解码
URL 编码/解码

URL 编码/解码

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具