• 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: Question about respondsToSelector
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about respondsToSelector


  • Subject: Re: Question about respondsToSelector
  • From: Chris Hanson <email@hidden>
  • Date: Mon, 18 Aug 2008 13:28:34 -0700

On Aug 18, 2008, at 11:17 AM, Carmen Cerino Jr. wrote:

Does the id type have enough information for the respondsToSelector method to work. I have a class with an ivar of type id, and when I invoke the respondsToSelector method it fails when it should succeed. I am assuming it should work fine, because if I skip checking with the respondsToSelector method and just make the call, it executes the method. Can someone please tell me what I am doing wrong?

What code are you using with -respondsToSelector: and to invoke the selector?


We need to see that in order to be able to say whether what you're doing will work.

On background: -respondsToSelector: is a message like any other message in Objective-C. It's not an operation on a type; you're actually sending a message to the object in question, which will use the Objective-C runtime to answer the question that's asked. So the static type of the variable referencing the object it's sent to -- in your case, "id" -- doesn't have anything to do with how the actual message behaves.

  -- Chris

_______________________________________________

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: 
 >Question about respondsToSelector (From: "Carmen Cerino Jr." <email@hidden>)

  • Prev by Date: Re: Problem with fileAttributesAtPath
  • Next by Date: Re: Question about respondsToSelector
  • Previous by thread: Re: Question about respondsToSelector
  • Next by thread: Re: Question about respondsToSelector
  • Index(es):
    • Date
    • Thread