Monday, October 25, 2010

NSDictionaryController Selection as the Content of another NSDictionaryController

Programmer Question

Basically I have two combo boxes whose content is bound to two NSDictionaryControllers, However the content of the second combo box depends on the selection of the first. How can I accomplish this in interface builder taking advantage of the fact that my objects are implement KVO pattern. It seems that the bookComboBox selection changing does impose a selection on the BookDictionaryController. I checked this by looking at [BookDictionaryController selection] inside the selectionDidChange delegate method of the bookComboBox, which was empty.



The object model looks like



subject = top level object that has a dictionary called books
books = dictionary of book objects, with the book title as the key.
book = book object with a title property and a dictionary called chapters
chapters = dictionary of Chapter objects, with the chapter name as the key
chapter = a chapter object.



In interface builder I did this:



BookDictionaryController content{

bound to : applicationController

model key path: subject.chapters

}



bookComboBox content{

bound to: BookDictionaryController

controller key: arrangedObjects

model key path: key

}//same for content values



ChapterDictionaryController{

bound to: BookDictionaryController

controller key: selection

model key path: value.chapters

}



chapterComboBox content{

bound to: ChapterDictionaryController

controller key: arrangedObjects

model key path: key

}//same for content values



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails