0

use this code

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textChanged:) name:NSTextDidChangeNotification object:self.text3];

I can not get the notification I wanted.

But if I change the name or object to nil, it works. I wonder whether these two arguments can not be set non-nil simultaneously?

  • You can have a try, I think you will get noticed of all the notifications posted by `NSNotificationCenter`. If you want more details about the name or object see the [NSNotificationCenter reference](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSNotificationCenter_Class/index.html) – KudoCC Oct 23 '14 at 08:23
  • I know the reason finally. My `text3` is a `NSTextField` object. And the actually object which fire the `NStextDidChangeNotification` is the associated `NSTextView` object. – kai pan Oct 27 '14 at 09:44

0 Answers0