MacOS-equivalent of "tableview:didSelectRowAtIndex"

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

  1. Danneman101 macrumors 6502

    Joined:
    Aug 14, 2008
    #1
    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: http://andrehoffmann.wordpress.com/2009/09/03/phonebook-tutorial-for-dummiesxcode-3-1-3/

    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

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
  3. Danneman101 thread starter macrumors 6502

    Joined:
    Aug 14, 2008
    #3
    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 603

    whooleytoo

    Joined:
    Aug 2, 2002
    Location:
    Cork, Ireland.
    #4
    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

    Joined:
    Dec 2, 2008
    #5
    Nib/Xib

    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

    Joined:
    Aug 14, 2008
    #6
    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 (http://developer.apple.com/library/...iewDelegate_Protocol/Reference/Reference.html).

    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