Re: getting a cell value [was: creating an NSTableColumn}
Re: getting a cell value [was: creating an NSTableColumn}
- Subject: Re: getting a cell value [was: creating an NSTableColumn}
- From: j o a r <email@hidden>
- Date: Fri, 16 Jul 2004 17:44:15 +0200
On 2004-07-16, at 17.16, John Spicer wrote:
>
I figured out the creation of the column (I think) using this code:
>
>
NSTableColumn *col = [[NSTableColumn alloc] init];
>
[col setIdentifier:@"MY_COLUMN"];
>
>
which I **think** is correct.
No, it's not correct. You MUST use the "designated initializer" when
creating new object instances. In this case it's incorrect in more ways
than one though - read on.
>
However, I want the value in that cell, I
>
thought this would do it:
>
>
NSString *tempPK = (NSString *) [self tableView:myView
>
objectValueForTableColumn:col row:[myView selectedRow]];
So you're trying to create a column to pass to your own data source
method to find the object value? That's very creative, but certainly
not the best way to find it...
That method is probably expecting to get the actual table column that
is in the actual table view. In any cases it doesn't matter which table
column you pass though, as you're sometimes more interested in the
table column identifier, and not the actual table column instance.
But back on track. Let's say that your data source has an array of
dictionaries to represent the rows in the table view. Now, if you want
to duplicate a row why don't you just locate the row in the array and
copy the dictionary? Why this roundabout way of creating columns and
going via the table view data source methods?
>
but it returns an id, which I don't (or can't? convert into a string).
The id you get back will be a string, so in a worst case scenario you
would have to cast it to a string - but you probably won't have to do
anything.
j o a r
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.