我想使用这个问题的答案中的代码: 如何观察 NSTextField上的 NSTextField 的值,以便观察存储在 NSTextField 中的字符串的变化。
[[NSNotificationCenter defaultCenter]
addObserverForName:NSTextViewDidChangeSelectionNotification
object:self.textView
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification *note){
NSLog(@"Text: %@", self.textView.textStorage.string);
}];
这里使用的类是一个 NSTextView。我在 NSTextField 中找不到要使用的通知来代替 NSTextViewDidChangeSelectionNotification。
在这种情况下可以使用 NSTextField 中的通知吗?