Re: NSTableView questions...
Re: NSTableView questions...
- Subject: Re: NSTableView questions...
- From: Thomas McQuitty <email@hidden>
- Date: Sat, 6 Sep 2003 22:36:21 -0600
That makes perfect sense, as I do have the data being displayed in the
NSTableView..
So, if I have a sort routine for the display, should I be resorting my
datasource? In this case it is a simple NSArray, but just for future
reference...
Thanks,
Thomas
On Saturday, September 6, 2003, at 10:06 PM, John Lombardo wrote:
Hola Thomas,
The reason for the datasource is that the NSTableView doesn't store
data,
like a listbox does. Instead, it it essentially an interface to your
datasource, using the methods:
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
And...
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
The object that has been assigned as the datasource must implement
both of
these, and are called by the NSTableView so it knows what to display.
The
first method it calls is numberOfRowsInTableView: which lets it know
how
many rows to display. The second method asks the datasource, "In
tableview
aTableView, for column aTableColumn, please tell me what object value
(eg. a
NSString, or NSNumber, or whatever) I should display row rowIndex"
Cheers,
john
On 7/9/03 11:26 AM, "Thomas McQuitty" <email@hidden> wrote:
Ok, please forgive my ignorance...
I am writing an application to export some data and I am still getting
used to Cocoa, as the breadth of my experience has been writing MFC
based applications...
I was thinking that NSTableView would be similar to a listbox, for
example, but the differences are astounding (I never had to create and
link a data source to a list box, for example).
In my Windows development, for a task like this, I would simply
iterate
through the list and determine the selected lines and perform a
GetWindowText, or some other method for getting the selected row's
contents. However, in Cocoa, I am finding no similar function.
Here's my issue, and I may be looking at it all wrong..
I run through and get a list of data...
The user will select one or more items from the NSTableView.
I go to process this data when they select a button...
Now, I need to get a list of the items selected (like NSTableView
-isRowSelected:) but I cannot see an easy way to translate this back
to
the text...
My questions are:
Am I approaching this the right way? Would scanning for the
correlated
data in the datasource object be the right way to go? Are these kept
correlated? (I assume not).
What would the proper approach be, from a cocoa perspective...
Thanks,
Thomas
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.