开发者

Multiple objects subscribing to an NSNotification (Objective-c)

I have an Obje开发者_开发技巧ctive-c class MyClass that subscribes to MyNSNotification. There are multiple instances of MyClass in my application. Hence multiple objects receive the notification. Is there a way to "filter" notifications for a particular object?

I imagine doing a check in the selector. I'm just not sure how to set it up.


Use userInfo for that purpose issuing notification. Recieving one check userInfo to decide if this notification targeted here or not. Sometimes enough to know who sent notification. Use object property for that. Consult class reference http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSNotification_Class/Reference/Reference.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜