• 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: NSSelectorFromString oddity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSSelectorFromString oddity


  • Subject: Re: NSSelectorFromString oddity
  • From: Shaun Wexler <email@hidden>
  • Date: Wed, 10 Nov 2004 20:28:21 -0800

On Nov 10, 2004, at 7:22 PM, Bruce Truax wrote:

I am attempting to use the NSSelectorFromString function to create a
selector. I have used this numerous times before and it has always worked
but something odd is happening this time. In this program thPikup is a
getter for a pointer to an object.


If I use:

        pikupSelector = NSSelectorFromString(@"thPikup");

        if ([lensSurface respondsToSelector:pikupSelector]){
            thePikup = [lensSurface thPikup];
            thePikup = [lensSurface performSelector:pikupSelector];

Then thPikup is the same for the last two lines.  If I use:

        selectorString = [[NSString alloc] initWithString:@"thPikup"];
        pikupSelector = NSSelectorFromString(pikupString);

        if ([lensSurface respondsToSelector:pikupSelector]){
            thePikup = [lensSurface thPikup];
            thePikup = [lensSurface performSelector:pikupSelector];

Then the first thPikup is the pointer to the correct object and the second
thPikup is a pointer to the lensSurface object. The weird thing is that the
test -respondsToSelector succeeds for both cases.


Does anyone see what is wrong?

Yes. pikupString is not defined in the above snippet's context...

In lieu of all that code, try this instead:

	thePikup = [lensSurface valueForKey:@"thPikup"];

HTH~
--
Shaun Wexler
MacFOH
http://www.macfoh.com

_______________________________________________
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


  • Follow-Ups:
    • Re: NSSelectorFromString oddity
      • From: Bruce Truax <email@hidden>
References: 
 >NSSelectorFromString oddity (From: Bruce Truax <email@hidden>)

  • Prev by Date: Re: Multiple Nibs
  • Next by Date: Confirming NSTextField when a button is pressed
  • Previous by thread: NSSelectorFromString oddity
  • Next by thread: Re: NSSelectorFromString oddity
  • Index(es):
    • Date
    • Thread