nsarraycontroller

How to get notified of changes to models via an NSArrayController?

▼魔方 西西 提交于 2019-11-30 00:52:39
I have an NSView subclass which is bound to the arrangedObjects of an NSArrayController . When the array has an item inserted or removed the view is notified. How do I get it to be notified if a model stored in the array has an attribute changed? Do I need to add my view as an observer to every (relevant) attribute of every item added to the array? When an item is added to or removed from the array I am notified via observeValueForKeyPath:ofObject:change:context: in my NSView subclass. I am not notified of changes to the models stored in the array but I could, every time I am notified of an

How to get notified of changes to models via an NSArrayController?

僤鯓⒐⒋嵵緔 提交于 2019-11-28 21:40:13
问题 I have an NSView subclass which is bound to the arrangedObjects of an NSArrayController . When the array has an item inserted or removed the view is notified. How do I get it to be notified if a model stored in the array has an attribute changed? Do I need to add my view as an observer to every (relevant) attribute of every item added to the array? When an item is added to or removed from the array I am notified via observeValueForKeyPath:ofObject:change:context: in my NSView subclass. I am

Using an NSArrayController in Multiple Storyboard Scenes

我的梦境 提交于 2019-11-28 06:59:11
I have a Mac document-based Core Data application that uses storyboards. The storyboard has the following layout: Window Controller Split View Controller Table View Controller Text View Controller My Core Data model contains a Chapter entity that contains two attributes: title and contents. I want the table view to show each chapter title. The text view shows the contents of the selected chapter. If I was using a xib file, I would add an array controller to the xib file. I would bind the array controller to File's Owner to access my NSPersistentDocument subclass. I would bind the table view to

Key Value Observing with an NSArray

时光总嘲笑我的痴心妄想 提交于 2019-11-27 18:34:41
I've looked on SO for examples of using Key Value Observing with an NSArray (or NSMutableArray ) and apparently you need to use an NSArrayController (which unlike KVO I'm not familiar with), but I haven't found concrete examples of how to do this. Can anyone explain with some sample code? For instance, if I have a GameModel which represents its player names with an NSArray (playerNameArray) of NSStrings . I want to observe those strings (the view controller observes the model's data) to update various things in the view. How do I get notification that the player name array has changed? EDIT :

Using an NSArrayController in Multiple Storyboard Scenes

主宰稳场 提交于 2019-11-27 01:39:15
问题 I have a Mac document-based Core Data application that uses storyboards. The storyboard has the following layout: Window Controller Split View Controller Table View Controller Text View Controller My Core Data model contains a Chapter entity that contains two attributes: title and contents. I want the table view to show each chapter title. The text view shows the contents of the selected chapter. If I was using a xib file, I would add an array controller to the xib file. I would bind the

Key Value Observing with an NSArray

不想你离开。 提交于 2019-11-26 19:31:20
问题 I've looked on SO for examples of using Key Value Observing with an NSArray (or NSMutableArray ) and apparently you need to use an NSArrayController (which unlike KVO I'm not familiar with), but I haven't found concrete examples of how to do this. Can anyone explain with some sample code? For instance, if I have a GameModel which represents its player names with an NSArray (playerNameArray) of NSStrings . I want to observe those strings (the view controller observes the model's data) to