• 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: Mike Abdullah <email@hidden>
  • Date: Wed, 20 Feb 2008 18:23:14 +0000

One further thing to take into consideration is the behavior of framework-generated dynamic subclasses. For example, KVO can create subclasses of your objects on-the-fly and pass them around in order to properly manage the KVO notifications.

With this I suspect that NSStringFromClass() will return the dynamic class name which will be different to what your code might expect. - className I believe will still return your object's intended class.

However, I haven't tested this properly; please somebody say if I'm wrong.

Mike.

On 20 Feb 2008, at 16:55, Dave Jewell wrote:

On 20 Feb 2008, at 15:44, glenn andreas wrote:

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.

Interesting - thanks for that. I was about to disagree with you 'cos className shows up in the standard documentation for NSObject, but if you use it in your code, then right-click on it and choose "Jump to definition", then you will indeed get shunted off to NSScriptClassDescription.h, which fits with what you said. :-)


Dave

_______________________________________________

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

_______________________________________________

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: "Kyle Sluder" <email@hidden>
References: 
 >NSStringFromClass versus className ? (From: Dave Jewell <email@hidden>)
 >Re: NSStringFromClass versus className ? (From: glenn andreas <email@hidden>)
 >Re: NSStringFromClass versus className ? (From: Dave Jewell <email@hidden>)

  • Prev by Date: Response from binding of NSPopUpButton
  • Next by Date: Re: How to draw a CGImage object to a NSView?
  • Previous by thread: Re: NSStringFromClass versus className ?
  • Next by thread: Re: NSStringFromClass versus className ?
  • Index(es):
    • Date
    • Thread