SundayMonday
SundayMonday

Reputation: 19757

Multiple objects subscribing to an NSNotification (Objective-c)

I have an Objective-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.

Upvotes: 0

Views: 393

Answers (1)

Valeriy Van
Valeriy Van

Reputation: 1865

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

Upvotes: 1

Related Questions