NSDictionaryController似乎没有观察到内容字典的更改 [英] NSDictionaryController doesn't seem to observe changes to content dictionary

查看:107
本文介绍了NSDictionaryController似乎没有观察到内容字典的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



TableViewColumn --bindsTo-> DictionaryController.arrangedObjects。(值或键)
--bindsTo->我已经测试了tableView,方法是在indictionary上添加一个条目(在init上正确显示)。但是,当另一种方法产生一个对象然后将其添加到aDictionary时,TableView似乎没有更新,甚至不知道aDictionary现在有两个条目。我已经尽力想了一切。我不是直接访问aDictionary...。我尝试过(在someClassMember中)[self aDictionary setValue:forKey:]和[self setValue:forKeyPath:@ aDictionary]和类似的变体。密钥是一个字符串,因此它应该符合KVC / KVO,并且我在someClassMember中有一个 @synthesize字典。



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



预先感谢

解决方案

在添加新项目之前尝试 [self willChangeValueForKey:@ aDictionary]; [self didChangeValueForKey:@ aDictionary]; 之后在 someClass


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

解决方案

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

这篇关于NSDictionaryController似乎没有观察到内容字典的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆