1
A
回答
3
您不会直接向某人发布通知。通知的名称和发件人决定谁获得通知。
感兴趣的对象可以订阅通知。当您发布通知时,通过该名称收听通知的所有订阅者都会收到通知。
- 通知名称(字符串)
- 发件人
的class documentation说明了这一点明确:其实可可通知可以在两个层次进行调整。
下面是显示谁得到这取决于通知名称和发件人创建通知时使用的文档有点ASCII表:
Notification name | Notification sender | Notification set specified -------------------------------------------------------------------- Specified | Specified | Notifications with a particular name from a specific sender. Specified | Unspecified | Notifications with a particular name by any sender. Unspecified | Specified | Notifications posted by a specific sender. Unspecified | Unspecified | All notifications.
不明指的是零值该字段提供。
通知允许松散耦合的设计,因为对象在其实现中没有绑定在一起,并且可以相互独立工作。
1
notification
是广播机制。从文档开始,“对象使用addObserver:selector:name:object:或addObserverForName:object:queue:usingBlock:methods,向通知中心注册以接收通知(NSNotification对象)。”即任何感兴趣的对象都可以注册为听众。
相关问题
- 1. NSNotificationCenter postNotificationName exec_badaccess
- 2. 谁是类方法的接收者?
- 3. postNotificationName没有要求观察者方法
- 4. 通过[[NSNotificationCenter defaultCenter] postNotificationName]方法直接传递对象是否危险?
- 5. 使用NSNotificationCenter接收通知
- 6. 如何调用具有相同名称的方法(NSNotificationCenter postNotificationName)?
- 7. 谁是观察者,谁是可观察者?
- 8. NSNotificationCenter通知不被发送/接收
- 9. 是否同步或异步接收NSNotificationCenter事件?
- 10. Javascript。执行者是谁?
- 11. 删除NSNotificationCenter观察者
- 12. NSNotificationCenter删除观察者
- 13. NSNotificationCenter和mapType
- 14. NSNotificationCenter不工作?
- 15. 从一个发送者/接收者并发地接收/发送
- 16. git:谁在推送后接收钩
- 17. 如何找出ROM提供者是谁?
- 18. AWS S3权限谁是AWS授予者?
- 19. 谁是POST方案中的使用者?
- 20. 如何知道.bashrc谁是发起者?
- 21. C和C++的所有者是谁?
- 22. Java多播发送者+接收者
- 23. 广播发送者和接收者对
- 24. UI测试+ postNotificationName +永远不会到达观察者+ Xcode 7
- 25. Swift NSNotificationCenter不会启动
- 26. Docusign更新接收者
- 27. 动态注册接收者
- 28. DocuSign API:专属接收者
- 29. 套接字和收听者
- 30. 接收者操作特征
我应该在代码中添加此NSnotificaton语句?我应该把它放在必须是听众的功能中吗? – Namratha 2011-02-11 04:13:16
@Namratha我建议你参考MoviePlayer示例http://developer.apple.com/library/ios/#samplecode/MoviePlayer_iPhone/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007798以供参考。 – ohho 2011-02-11 06:33:07