NSDictionaryController 似乎没有观察到内容字典的更改

发布于 2024-08-08 13:34:17 字数 653 浏览 4 评论 0原文

我一定错过了一些简单的东西,但是我在将 tableView 绑定到 NSDictionaryController 时遇到了一些麻烦。这是我当前方案的模型:

TableViewColumn --bindsTo-->DictionaryController.arrangedObjects.(value or key) --bindsTo-->someClass.someClassMember.aDictionary。

我通过在 init 上向字典添加一个条目来测试 tableView,该条目显示正确。但是,当另一个方法生成一个对象,然后将其添加到 aDictionary 中时,TableView 似乎不会更新,甚至不知道 aDictionary 现在有两个条目。我已经尝试了我能想到的一切。我直接访问aDictionary ....我尝试过(在某些ClassMember中)[self aDictionary setValue:forKey:]和[self setValue:forKeyPath:@“aDictionary”]和类似的变体。键是一个字符串,因此它应该符合 KVC/KVO 规范,并且我在 someClassMember 中添加了“@synthesize”字典。

我缺少什么?为什么字典中的新条目不会显示在 tableView 中?

提前致谢

I must be missing something simple, but I am having some trouble binding a tableView to an NSDictionaryController. Here is a model of my current scheme:

TableViewColumn --bindsTo-->DictionaryController.arrangedObjects.(value or key)
--bindsTo-->someClass.someClassMember.aDictionary.

I've tested the tableView by adding an entry to aDictionary on init, which is displayed correctly. But when another method produces an object that is then added to aDictionary, the TableView doesn't seem to update or even know that aDictionary now has two entries. I've tried everything I can think of. I am not directly accessing aDictionary....I've tried (in someClassMember) [self aDictionary setValue:forKey:], and [self setValue:forKeyPath:@"aDictionary"] and similar variations. The key is a string, so it should be KVC/KVO compliant, and I have '@synthesize'd aDictionary in someClassMember.

What am I missing? Why won't new entries to the dictionary show up in the tableView?

Thanks in advance

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

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

发布评论

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

评论(1

叹沉浮 2024-08-15 13:34:17

在添加新项目之前尝试 [self willChangeValueForKey:@"aDictionary"];,然后在 someClass 中尝试 [self didChangeValueForKey:@"aDictionary"];代码>

Try [self willChangeValueForKey:@"aDictionary"]; before adding the new item, and [self didChangeValueForKey:@"aDictionary"]; afterwards in someClass

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