Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 使用NSNotification委托NSTextField的方法_Objective C_Cocoa_Macos_Delegates - Fatal编程技术网

Objective c 使用NSNotification委托NSTextField的方法

Objective c 使用NSNotification委托NSTextField的方法,objective-c,cocoa,macos,delegates,Objective C,Cocoa,Macos,Delegates,我在窗户里有一块空地。我使用它来存储与核心数据对象相关的标记。现在我已经将其设置为可以向对象添加标记,但不能删除它们。我需要一个NSTokenField上的委托方法,该方法可以让我知道用户何时已将焦点移出NSTokenField。由于NSTokenField是NSTextField的一个子类,我想我可以使用它的委托方法。它有两个我认为可能有用的方面: - (void)textDidChange:(NSNotification *)aNotification - (void)textDidEndE

我在窗户里有一块空地。我使用它来存储与核心数据对象相关的标记。现在我已经将其设置为可以向对象添加标记,但不能删除它们。我需要一个NSTokenField上的委托方法,该方法可以让我知道用户何时已将焦点移出NSTokenField。由于NSTokenField是NSTextField的一个子类,我想我可以使用它的委托方法。它有两个我认为可能有用的方面:

- (void)textDidChange:(NSNotification *)aNotification
- (void)textDidEndEditing:(NSNotification *)aNotification

我将控制器类设置为NSTokenField的委托,并将这两个方法都放入控制器类中。我将一个基本的NSLog放入其中的每一个,当我与NSTokenField交互时,两者都不会被触发。我猜这与通知有关。如何激活这些方法?

NSTokenField调用
controlTextDidChange:
controlTextDidEndEditing:
通知;更改上述两种方法,将其实现为:

- (void)controlTextDidChange:(NSNotification*)aNotification
{
    //Code here..
}

- (void)controlTextDidEndEditing:(NSNotification *)aNotification
{
    //Code here..
}