I am someone with past experience of C++ and MFC who is trying to get started with Objective-C and Cocoa development. I have some books ordered to help me, but they haven't turned up yet, so I'm stuck trying to figure stuff out from the XCode help and http://developer.apple.com/documentation/Cocoa/. I did the Currency Converter tutorial and now am sort of wandering the API around aimlessly.
Today I am trying to make a decent stab at a NSTableView. I have added an NSTableView to my .nib, and set my controller as a dataSource. I have added the two methods numberOfRowsInTableView and what I guess could be called objectValueForTableColumn to my controller and I am able to populate the NSTableView by returning sensible results from those two methods. I am returning NSStrings for objectValueForTableColumn.
I have two questions. Firstly, what is the "correct" way to use the value passed as an (NSTableColumn *) to objectValueForTableColumn? At the minute I'm just doing [[tableColumn headerCell] stringValue] and comparing that to what I know are the column headers. That works, but strikes me as a very roundabout way of doing things and prone to localisation problems.
Secondly, how do I stop my NSTableView from being editable? What I really want is to receive a message on a row double click that will be responded to by actions in my model class. I have not implemented setObjectValue, which I thought would be enough to prevent editing but it doesn't seem to be. I want dragging and dropping so I need to implement validateDrop and forDraggedRowsWithIndexes, but I haven't done that yet.
Thanks in advance, and sorry for asking what are probably very basic questions that will have easy and easily discoverable answers once I have books.
Today I am trying to make a decent stab at a NSTableView. I have added an NSTableView to my .nib, and set my controller as a dataSource. I have added the two methods numberOfRowsInTableView and what I guess could be called objectValueForTableColumn to my controller and I am able to populate the NSTableView by returning sensible results from those two methods. I am returning NSStrings for objectValueForTableColumn.
I have two questions. Firstly, what is the "correct" way to use the value passed as an (NSTableColumn *) to objectValueForTableColumn? At the minute I'm just doing [[tableColumn headerCell] stringValue] and comparing that to what I know are the column headers. That works, but strikes me as a very roundabout way of doing things and prone to localisation problems.
Secondly, how do I stop my NSTableView from being editable? What I really want is to receive a message on a row double click that will be responded to by actions in my model class. I have not implemented setObjectValue, which I thought would be enough to prevent editing but it doesn't seem to be. I want dragging and dropping so I need to implement validateDrop and forDraggedRowsWithIndexes, but I haven't done that yet.
Thanks in advance, and sorry for asking what are probably very basic questions that will have easy and easily discoverable answers once I have books.