NSTableView 绑定和观察者

发布于 2024-12-21 20:47:18 字数 631 浏览 2 评论 0原文

我正在尝试使用绑定向 NSTableview 添加新行。根据过去的一篇文章,我被指示在数组控制器上添加对象,并且 KVO 应该处理视图的通知。但是,

我收到以下错误:

An -observeValueForKeyPath:ofObject:change:context: message was received but not handled.
Key path: accountArray
    Observed object: <AppDelegate: 0x10011e3b0>
Change: {
     indexes = "<NSIndexSet: 0x102915ba0>[number of indexes: 1 (in 1 ranges), indexes: (2)]";
     kind = 2;
}

我已在我的应用程序委托中添加了此观察者:

[self addObserver:self forKeyPath:@"accountArray" options:0 context:@"myContext"];

我还尝试实现observerValueforKeyPath,但当我调试我的代码时永远不会达到这一点。

我做错了什么?

I am trying to add a new row to an NSTableview using bindings. According to a past post I was instructed to addObject on the array controller and the KVO should handle the notification to the view. However,

I get the following error:

An -observeValueForKeyPath:ofObject:change:context: message was received but not handled.
Key path: accountArray
    Observed object: <AppDelegate: 0x10011e3b0>
Change: {
     indexes = "<NSIndexSet: 0x102915ba0>[number of indexes: 1 (in 1 ranges), indexes: (2)]";
     kind = 2;
}

I have added this observer in my App Delegate:

[self addObserver:self forKeyPath:@"accountArray" options:0 context:@"myContext"];

I have also tried to implement the observerValueforKeyPath but when I debug my code never gets to this point.

What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一张白纸 2024-12-28 20:47:18

您必须实现该方法:

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context

You must implement that method:

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文