My data is in the form of a sugar (NSMutableArray) list when I retrieve it from my web server. It isn’t really a big problem assign variables the values of each and then getting the values as they’re posted but I figured that Cocoa Bindings would make this easy. All the samples I see on the web are using Core Data but I simply have an array of records/classes that are retrieved from a website and then posted back as changes are made.
So, I was wondering if the same array could populate a view based table view with corresponding detail data on the same window.
I just need a simple example of an array assigned to the content of an NSArrayController (got that) and then what to do to the xib file in interface builder to make it all work.
Assuming its an NSTableView, I think its the following
Bind the Table Content to the NSArrayController
Bind the SelectionIndexes of the NSArrayController to the Selection Indexes of the NSTableView
If you expand the NSTableView in interface builder you should be able to select individual columns
In column bind the value to the NSArrayController, controller key is arrangedObjects and the Model key path is the property on the object in the array. For example I have a controller called sailedController and the object in the array has a property called Boat. The binding would be sailedController.arrangedObjects.self.Boat
I’m trying this with a very simple example program
Done
Bind to "OptionArray"
Controller Key = arrangedObjects
Model Key Path = ?
Don’t even know where to start on this. When I view the Selection Indexes of the NSArrayController, the only items I can bind to are the “Appliction”,“File’s Owner”, and “Shared User Defaults Controller”.
I have 3 columns and 3 string values in my array. For each column, the value is bound to “OptionArray”, controller key is “arrangedObjects” (by default), and the Model Key Path is just the names of the string properties.
The result so far is that I have a tableview with 3 columns and 3 rows displaying. Each cell displays “Table View Cell”.
I’m not sure where to go from here. Any help is greatly appreciated.
Getting much closer. The tableview needed to be changed to cell based instead of view based. I can see the values. Now to see if I can manipulate values.