views:

181

answers:

1

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

+1  A: 

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

ctshryock
This helped, in that it revealed a problem that one of the objects in aDictionary did not implement 'copyWithZone' properly. But even after correcting that, I still need [self will/didChangeValueForKey]. I guess I don't understand KVC enough. What about my design keeps the dictionaryController or tableView from observing a dictionary whose contents are changed programatically? I should be KVC compliant, why do I need to manually notify?
Dan Sasson