Simple NSTableView bindings example

Posted by sirjorj on Stack Overflow See other posts from Stack Overflow or by sirjorj
Published on 2010-05-29T02:18:45Z Indexed on 2010/05/29 2:22 UTC
Read the original article Hit count: 343

I am trying to populate a 2-column NSVTableView via bindings, but the data is not showing up in the table.

In XCode:

I have a NSMutableArray in my AppDelegate that will hold the data, as well as the corresponding @property and @synthesize.

On an event, I call [removeAllObjects] on the NSMutableArray and repopulate it with some NSDictionary objects. Each dictionary contains 2 KVP's: a NAME and a VALUE.

In IB:

I added an NSArrayController and bound it's Content Array to my AppDelegate and set the ModelKeyPath to the name of the NSMutableArray in the AppDelegate.

On the NSTableView, I bound the Content to the ArrayController. ControllerKey = "arrangedObjects", ModelKeyPath = empty.

For each of the two columns, I bound the Value to the AppController and set the ModelKeyPaths to NAME and VALUE respectively. ControllerKey = "ArrangedObjects".


I have tried several other things, such as using an NSArray in the app delegate and making a new one every time I need to update the values. There must be some tiny little thing I am forgetting. What is it?

jorj

© Stack Overflow or respective owner

Related posts about nsarray

Related posts about cocoa-bindings