I have an ASOC program that has a table and graph where the data can be changed on the fly via 2 sliders, but it’s a little slow, so I’m converting some of it to ObjC. I need help figuring out how to get the data to show up in the table. The Obj C code I have is :
I call makeArray: from the AS, and the NSLog statement shows the correct data, but nothing shows up in the table. (the content array of the array controller is bound to theData). Also, when I try to add new data via addData: both NSLogs in that method show theData to be NULL. I’m sure I’m missing something simple here, as I have little experience in Obj C coding.
the scope of variables is almost the same as in AppleScript. local variables (like theData in your example) are visible only in the method where they are created in. instance variables are globals, which are declared in the interface file. They are visible everywhere in the class.
To populate a table view in Objective-C you can use a NSArrayController via bindings or
you must implement the basic table view data source delegate methods numberOfRowsInTableView: and tableView:objectValueForTableColumn:row:
It’s not recommended to use class methods +(returnClass)method for this purpose.
Here is a simple example, you have to specify the table column identifer “rawScore” in Interface Builder,
Sorry, here is the whole code so far. I was trying to populate the table through bindings to theData like I do in ASOC (the content of the array controller is bound to controller.theData and the column is bound to Array Controller.arrangedObjects.rawScore). Is that possible in Obj C?
I found out that having my AS (which is the app delegate) be a subclass of my objective c class was somehow screwing things up. I changed the parent back to NSObject and changed some theDatas to self.thedatas and now the table gets populated, and the addData method works as well.