• 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: NSStringFromClass versus className ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSStringFromClass versus className ?


  • Subject: Re: NSStringFromClass versus className ?
  • From: glenn andreas <email@hidden>
  • Date: Wed, 20 Feb 2008 09:44:40 -0600


On Feb 20, 2008, at 9:15 AM, Dave Jewell wrote:

I've seen lots of Cocoa code which uses NSStringFromClass to obtain the name of a particular class, but relatively little code which uses NSObject's built-in className method. Is there a particular reason for this? Is there some hidden 'gotcha inside className waiting to bite me?


Probably because className is part of the scripting extensions. As a result, you won't see it if you browse NSObject.h (so it's not an obvious idiom), plus everybody knows that AppleScript related stuff is "icky". Well, maybe not so much the second part, but the first part is true.

NSStringFromClass also has the advantage that it works for all classes - not just those that inherit from NSObject. So if I remember correctly, doing NSStringFromClass on something that is a proxy will return NSProxy, while className will give you whatever the proxy is proxying.


Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next generation of fractal art




_______________________________________________

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: NSStringFromClass versus className ?
      • From: Dave Jewell <email@hidden>
    • Re: NSStringFromClass versus className ?
      • From: j o a r <email@hidden>
References: 
 >NSStringFromClass versus className ? (From: Dave Jewell <email@hidden>)

  • Prev by Date: Problem with NSStream newbie question
  • Next by Date: DO in all run loop mode
  • Previous by thread: NSStringFromClass versus className ?
  • Next by thread: Re: NSStringFromClass versus className ?
  • Index(es):
    • Date
    • Thread