How do I get something like performSelector:(SEL) withObjects:(NSArray *)?
How do I get something like performSelector:(SEL) withObjects:(NSArray *)?
- Subject: How do I get something like performSelector:(SEL) withObjects:(NSArray *)?
- From: Christoffer Lernö <email@hidden>
- Date: Sun, 25 Sep 2005 01:10:01 +0200
Hello everyone,
I have a small problem looking for a nice solution.
I want to dynamically call different methods on a delegate. Normally
I'd use performSelector, but the method (and consequently the
arguments) cannot be restricted to 0 or 1.
The arguments are all stored in an NSArray, and the selector itself
is actually described in the same manner, being assembled before the
call is made.
Now, the way I made this work was to create an NSInvocation, having
to go by way of NSMethodDefinition etc etc. copying all the argument
pointers first into a c-style array and then moving them to into
NSInvocation, all the way I got a feeling I was doing the whole thing
wrong.
After writing some really hideous code, I got it to work.
However, there just has to be some simpler way of doing this, or?
How do I create something efficient that would be suitable as a
category to NSObject?
I was thinking it should look something along the lines of:
-(void)performSelector:(SEL)aSelector withObjects:(NSArray *)anArray
/Christoffer
_______________________________________________
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