Skip navigation.
 
mlRe: A documentation dumdum
FROM : William Squires
DATE : Sun Jun 22 18:46:41 2008

Okay, thanks. It seems to work if I just typecast it to NSString *, 
since the values are coming from an NSTextField as [textField 
stringValue] in my AppController.m when the action is triggered from 
the "Add" buttton.

On Jun 22, 2008, at 11:13 AM, Jeff LaMarche wrote:

>
> On Jun 22, 2008, at 12:02 PM, William Squires wrote:
>

>> okay, looking up tableView:setObjectValue:forTableColumn:row shows 
>> that setObjectValue: takes an (id), but what is it really? An 
>> NSString pointer? I want to get an NSString that represents the 
>> new value the user typed in for the selected (and edited) cell in 
>> the NSTableView. Can I safely typecast this to (NSString *)? In 
>> which case, maybe the docs should say that this is an (NSString *) 
>> instead of (id)?

>
> The documentation is correct. The Table View Programming Guide states:
>
> The NSTableView object treats objects provided by its data source 
> as values to be displayed in NSCell objects. If these objects 
> aren’t of common value classes—such as NSString, NSNumber, and so on
> —you may need to create a custom NSFormatter object to display 
> them. For more information, see Data Formatting Programming Guide 
> for Cocoa.
>
> In other words, it's not always going to be an NSString *. Whatever 
> the object is, it will be converted to a string for display, but 
> the table view is actually capable of holding different types of 
> data and doesn't change the type that it's holding, so you can't 
> assume that the object it holds is a string. Now, if you are giving 
> the table strings, then by all means, cast the object to an 
> NSString. If you're not sure what the type of object you're getting 
> back is, you can find out in the debugger console by typing
>
> po [returnedValue class]
>
> or adding an NSLog statement to your code like
>
> NSLog(@"returned value class: %@", [returnedValue class]);
>
> HTH
>

Related mailsAuthorDate
mlA documentation dumdum William Squires Jun 22, 18:02
mlRe: A documentation dumdum Jeff LaMarche Jun 22, 18:13
mlRe: A documentation dumdum Daniel Richman Jun 22, 18:14
mlRe: A documentation dumdum Jens Alfke Jun 22, 18:22
mlRe: A documentation dumdum William Squires Jun 22, 18:46
mlRe: A documentation dumdum Quincey Morris Jun 22, 21:44