Bindings and arrays generated/changed in code


#1

Hi all,

I recently followed a Beginning Cocoa BNR coarse, which was great. So now I am going through the book again and try to go a littler further in each chapter.

Using the chapter 8 code as an example, I wrote a small program (not document based) that has an nstableview and an array controller, which in turn is populated by a mutable array “radiologists” with pointers to “Radiologist” objects. I created this array and filled it in the app delegate, in the applicationDidFinishLaunching: method. As far as I can tell, all bindings and other settings are in place.

The array gets properly filled as confirmed with NSLog. But the nstableview stays empty, even though I bound it to the array radiologists. :open_mouth: The columns are defined to look at the ivars of the “Radiologist” objects.

When I add a button to my window and connect its action to add: in the nstableview, the entire array appears when I press the button!

Am I forgetting something? I would say that the moment of filling the array is not so important as long as its contents are bound to the tableview.

Thanks,

Mark

(EDIT Intro on Feb 20th)


#2

I’d say that I do not need to tell the tableview that the controller’s array changed, since the two items are bound. Would that be correct? If so, I guess I need to look into the way I did the bindings…