开发者

Is it possible to limit targets of NSNotification?

I want to send a NSNotification to a specific object (to self), without having other objects see / respond to it.

开发者_如何学Go

Is this possible without editing the other objects?


Well, if you really must use the same notification name, one thought would be to put the self pointer into userInfo. Then on the observer side, if you don't see a self pointer then you assume it's a general notification, not specific to any particular observer.

If you do see a self pointer, you compare it to yourself to decide if to handle it. I'm not sure it satisfies your constraint of "no edits", but it does at least satisfy the requirement that the superclass code doesn't need to know of all the possible subclasses.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜