Re: NSSelectorFromString oddity
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