开发者

NSDictionaryController doesn't seem to observe changes to content dictionary

开发者 https://www.devze.com 2022-12-09 03:50 出处:网络
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:

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 meth开发者_开发问答od 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

0

精彩评论

暂无评论...
验证码 换一张
取 消