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

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
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...
 
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...
 
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.
 
Nib/Xib

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...).

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.
 
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) :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.