• 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: Bruce Truax <email@hidden>
  • Date: Thu, 11 Nov 2004 06:47:48 -0500

I guess I need to stop coding after 10:00pm.  I changed the name of a string
variable and did not use the correct one.  Thanks for catching that.  I
stared at that error for an hour and did not catch it.

Bruce


On 11/10/04 11:28 PM, "Shaun Wexler" <email@hidden> eloquently wrote:

> 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~


 _______________________________________________
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: 
 >Re: NSSelectorFromString oddity (From: Shaun Wexler <email@hidden>)

  • Prev by Date: Advice for cross-platform equivalent of NSFileWrapper
  • Next by Date: Re: NSView & border
  • Previous by thread: Re: NSSelectorFromString oddity
  • Next by thread: Confirming NSTextField when a button is pressed
  • Index(es):
    • Date
    • Thread