Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

C. Alan

macrumors 6502
Original poster
Jan 23, 2009
310
5
I am learning Cocoa Programming by working my way through the Big Nerd Ranch book, " Cocoa Programming for Mac OS X", forth edition. The book is a bit dated, but it is still teaching me the basics.

So my questions:
1. I am trying to set up a table view that is controlled by an instance of NSArrayConroller. My table view has two columns, and I would like to make it selectable, but only allow the user to edit the item in the first column. How can I lock the second column against editing?

2. Is there an NSArrayController delegate or method that I can use to be alerted when the user makes an edit to the table?

Thanks,
C. Alan
 
Last edited:
Look at the Attributes inspector for the table column and NSTableViewDelegate

How can I lock the second column against editing?
Two ways ( both ultimately doing the same thing ):

(1) In the nib for the table column just deselect the "editable" checkbox in the Attributes Inspector

editable.png


(2) Use the setEditable: method on the table column when the table appears


2. Is there an NSArrayController delegate or method that I can use to be alerted when the user makes an edit to the table?
NSTableViewDelegate provides NSTableView objects a way to intercept many common user actions. All you have to do is implement the delegate method. Apple's docs are here: https://developer.apple.com/library/mac/documentation/cocoa/reference/NSTableViewDelegate_Protocol/Reference/Reference.html
 
Last edited:
Thanks for the help. I didn't think to look at the Table View delegates.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.