Problem with a table view controller bound to a list of script objects

I’m trying to learn to use array controllers with table views and got things working with a multicolumn table and an array controller bound to an array of dictionaries. However, when I tried to do the same with an array controller bound to an array of script objects, I’m running into problems.

My ASObjC application set-up is as follows. I created a main application class called MainScript, which is run by the app delegate on start-up. MainScript has a property named taskScripts whose value is a list that will be bound to the array controller for the table. I also created a class named TaskScript with properties taskMessage, taskTime, and taskFeatures, whose values I would like to display in a three-column table. When the application is run, MainScript creates instances of TaskScript, assigns text string values to each TaskScript’s taskMessage, taskTime, and taskFeatures properties, then adds the TaskScript objects to its taskScripts list.

In MainMenu.xib, a table view with three columns corresponding to taskMessage, taskTime, and taskFeatures has been added to the application window. An array controller object is created, and its Object Controller class name attribute is set to TaskScript. The array controller is bound to MainScript with the following settings: Controller Contents → bound to MainScript, Controller Key = empty, Model Key Path = taskScripts, and Handles Content As Compound Value = on. The text cell for each of the three table columns is bound as follows: Value → bound to Array Controller, Controller Key = arrangedObjects, Model Key Path = taskMessage, taskTime, or taskFeatures depending on the table column.

When I run the application, the window with the table opens, but nothing displays in the table columns. Can you please help me understand where I am going wrong. As I mentioned, things worked well with a similar set-up except that taskScripts consisted of an array of dictionaries rather than an array of script objects.

I’m fairly sure you will have to implement taskMessage, taskTime, and taskFeatures as handlers – eg, “on taskMessage” and “on setTaskMessage”.

I’m not sure how to implement the getter, since Applescript doesn’t allow a property and a handler to have the same name. I tried giving the property a different name while keeping the getter and setter names the same as the Model Key Path names, but I still get an empty table.

As a further point of confusion, in the first iteration of your example in Chapter 7 (A Class of Our Own) in “AppleScriptObjC Explored 5” of an array controller with script objects, you describe script object properties without explicitly implementing getters and setters, so I didn’t think it was going to be necessary. And to add to my woes, I can’t get that first iteration to work either.

I hope I’m not missing some minuscule erroneous setting, because I tried to follow your instructions exactly. And as I mentioned, I am able to get an array controller populated by records/dictionaries to work.

Can you email me the project?

Just a quick update, I got your example working. I was binding the script object properties to the text field cell objects rather than the table column objects. Once I made that change, it worked fine. The devil is in the details! My problem now is that I can’t figure out a way to add script objects to the array controller programmatically. I’ll email you the project. Thank you as always for your great help.