• 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: Selector not working for me
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Selector not working for me


  • Subject: Re: Selector not working for me
  • From: Andy Lee <email@hidden>
  • Date: Mon, 2 May 2005 11:20:41 -0400


On May 2, 2005, at 2:03 AM, Phil Larson wrote:

On May 1, 2005, at 5:55 AM, John James wrote:


if ([Seltest respondsToSelector: @selector(test1:)]==YES) NSLog(@"YES"); else NSLog(@"NO");

I always get NO!
Shouldn't it be YES?
Thanks for your help

John,

You need to make an instance of Seltest first.

Or use +instancesRespondToSelector:, as follows:

    if ([Seltest instancesRespondToSelector: @selector(test1)])
        NSLog(@"YES");
    else
        NSLog(@"NO");

You can use this method, for example, if you aren't sure you *want* to create an instance of the class, and your decision depends on whether it would respond to the selector.

--Andy

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Selector not working for me (From: John James <email@hidden>)
 >Re: Selector not working for me (From: Phil Larson <email@hidden>)

  • Prev by Date: Re: Date / time localisation
  • Next by Date: Re: Cocoa Technologies Back-Story?
  • Previous by thread: Re: Selector not working for me
  • Next by thread: Re: Selector not working for me
  • Index(es):
    • Date
    • Thread