Re: Calling a method based on a string
Re: Calling a method based on a string
- Subject: Re: Calling a method based on a string
- From: Fritz Anderson <email@hidden>
- Date: Mon, 11 Oct 2004 09:57:40 -0500
... and it goes without saying that if the method in question takes a parameter, its signature is
drawRect:, not
drawRect.
-- F
On 10 Oct 2004, at 11:48 PM, Jacob Lukas wrote:
On Oct 10, 2004, at 9:42 PM, Lee Morgan wrote:
I've looked though tons of docs and tried my best to search the archives for this; but I just can't find a answer....
Is it possible to call a method at runtime when all my app knows is a string of the method?
For example object A has a string called "drawRect" and a rectangle called myDrawRect
Then I want object B to perform drawRect with myDrawRect as it's parameter.
So it would be something like [objectB doMethod:@"drawRect" withParameter:myDrawRect];
[objectB performSelector:NSSelectorFromString(@"drawRect") withObject:myDrawRect];
of course it's better to do this:
[objectB drawRect:myDrawRect];
_______________________________________________
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