• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: A documentation dumdum
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A documentation dumdum


  • Subject: Re: A documentation dumdum
  • From: Jeff LaMarche <email@hidden>
  • Date: Sun, 22 Jun 2008 12:13:45 -0400


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

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: A documentation dumdum
      • From: William Squires <email@hidden>
    • Re: A documentation dumdum
      • From: Jens Alfke <email@hidden>
References: 
 >A documentation dumdum (From: William Squires <email@hidden>)

  • Prev by Date: A documentation dumdum
  • Next by Date: Re: A documentation dumdum
  • Previous by thread: A documentation dumdum
  • Next by thread: Re: A documentation dumdum
  • Index(es):
    • Date
    • Thread