Resolved NSArrayController and table view

Discussion in 'Mac Programming' started by C. Alan, Sep 2, 2014.

  1. C. Alan, Sep 2, 2014
    Last edited: Sep 3, 2014

    C. Alan macrumors 6502

    Joined:
    Jan 23, 2009
    #1
    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
     
  2. briloronmacrumo, Sep 2, 2014
    Last edited: Sep 2, 2014

    briloronmacrumo macrumors 6502

    briloronmacrumo

    Joined:
    Jan 25, 2008
    Location:
    USA
    #2
    Look at the Attributes inspector for the table column and NSTableViewDelegate

    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

    [​IMG]

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


    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
     
  3. C. Alan thread starter macrumors 6502

    Joined:
    Jan 23, 2009
    #3
    Thanks for the help. I didn't think to look at the Table View delegates.
     

Share This Page