• 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: class_respondsToSelector() in runtime.h?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: class_respondsToSelector() in runtime.h?


  • Subject: Re: class_respondsToSelector() in runtime.h?
  • From: Kyle Sluder <email@hidden>
  • Date: Thu, 1 Jul 2010 09:36:18 -0700

On Jul 1, 2010, at 9:14 AM, Michael Ash <email@hidden> wrote:

> On Thu, Jul 1, 2010 at 12:05 PM, Michael Ash <email@hidden> wrote:
>> An extremely minor nitpick: the use of +class here is necessary.
>
> Of course I meant to write that the use of +class here is UNnecessary. Sigh.

And it can actually get you into trouble. +class returns self, so this won't do what you might think at first:

[[SomeClass class] instancesRespondToSelector:@selector(foo)]

One might think that asks if the SomeClass class object responds to foo, following the logic that [SomeClass class] would return SomeClass's metaclass. In fact, as Mike describes, it is equivalent to [SomeClass instancesRespondToSelector:@selector(foo)].

--Kyle Sluder_______________________________________________

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

References: 
 >Re: class_respondsToSelector() in runtime.h? (From: Michael Ash <email@hidden>)
 >Re: class_respondsToSelector() in runtime.h? (From: Michael Ash <email@hidden>)

  • Prev by Date: Re: Error when closing window with IKImageBrowserView in it
  • Next by Date: Re: Error when closing window with IKImageBrowserView in it
  • Previous by thread: Re: class_respondsToSelector() in runtime.h?
  • Next by thread: KVO question
  • Index(es):
    • Date
    • Thread