MacOS-equivalent of "tableview:didSelectRowAtIndex"

Discussion in 'Mac Programming' started by Danneman101, Jan 12, 2011.

  1. Danneman101 macrumors 6502

    Aug 14, 2008
    I've just started MacOS-programming from having done some iOS-programming, and am finding a lot of things that differ, especially on how to set up a tableview.

    I've managed to set up a simple tableview and populate it via a plist using this tutorial:

    However, I'm at a loss to how to register pressing a row/cell. In iOS I used the "didSelectRowAtIndex", but that's apparently not how to do it in MacOS.

    So my question is: what's the equivalent of that function in macos? Or rather, is there perhaps a conversion-tutorial/docs anywhere? I've looked, but found nothing...
  2. lee1210 macrumors 68040


    Jan 10, 2005
    Dallas, TX
  3. Danneman101 thread starter macrumors 6502

    Aug 14, 2008
    No offense taken - and I understand you question. Well, I've tried learning Obj-c mainly trough using tutorials, and have focused on coding rather than using the nib-file (which I can't seem to wrap my head around - all these linkages...).

    In this project, though, I probably made a misstake in setting up my tableview using the nib-file. It has somewhat thrown me off to what needs to be done in order to get the tableview to register all the events (like clicking a cell, etc).

    I've just bought a book, though, called "Beginning Mac Programming" by Tim Isted, which probably will give me the insight I need. Read a couple of chapters so far...
  4. whooleytoo macrumors 604


    Aug 2, 2002
    Cork, Ireland.
    Look at the NSTableViewDelegate protocol documentation, there are a variety of actions you can respond to, dependent on your needs.

    Just make one of objects the delegate of your NSTableView, then implement the method you choose.
  5. PatrickCocoa macrumors 6502a

    Dec 2, 2008

    Best of luck. I don't know if your question got answered, but keep plugging away at the tutorials and books, and ask as many questions here as you want.

    You'll need to get very comfortable with nib/xib if you want the full experience.
  6. Danneman101 thread starter macrumors 6502

    Aug 14, 2008
    Thanks for your support. Well, I tried linking the delegate of the tableView in the nib-file to my tableviewcontroller-object, and finally I was able to use the functions in the tableviewdelegate-api in my tableviewcontroller (

    The appropriate function for recording a press of a cell seemed to be tableView:shouldTrackCell, and the rest of the functions will soon come in handy :)

    I realize I will have to put an effort into learning to use the nib-files appropriately - that will be my focus in the time to come I think.

    Thanks again for you input - I appreciate you taking the time to rather guide me in the right direction instead of giving the outright answer (give a man a fish...and so on) :)

Share This Page