Re: performSelector: question
Re: performSelector: question
- Subject: Re: performSelector: question
- From: Stéphane Sudre <email@hidden>
- Date: Tue, 27 Jul 2004 17:36:46 +0200
On Jul 27, 2004, at 5:34 PM, Bruce Truax wrote:
I am writing a parser for test input strings. Each string starts with
a
keyword and is followed by 0 or more text or numeric arguments. I
thought a
nice way to handle the processing of each string would be to create
methods
with the same names as each keyword. I would then extract the keyword
from
the string and call the method with that name passing the rest of the
string
as an argument. The NSObject documentation describes the
performSelector:
withObject method which would appear to do the job. The documentation
describes two ways to call this method:
id myClone = [anObject performSelector:@selector(copy)];
id myClone = [anObject performSelector:sel_getUid("copy")];
It would appear that the second method would work if I extracted the
keyword
as follows:
id myClone = [anObject performSelector:sel_getUid([keywordString
cString])
withObject:[restOfString]];
Is this the proper way to call a method using a string name?
FOUNDATION_EXPORT SEL NSSelectorFromString(NSString *aSelectorName);
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.