How to pass 3 parameters to @selector

ios, iphone, objective-c

Solution

You could add your parameters to a `NSArray` and then give it as the argument to your selector:

NSArray *params = [NSArray arrayWithObjects:@"a str", [NSNumber numberWithInt:42],myObj];
[self performSelector:@selector(myMethod:)withObject:params];

And then unpack the arguments in your method:

-(void)myMethode:(NSArray*)params
{
    NSString *strArg = [params objectAtIndex:0];
    NSNumber * numVal = [params objectAtIndex:1];
    NSObject *objArg = [params objectAtIndex:2];
    int intArg = [numVal intValue];
    .
    .
    .   
}

Problem

I created an action in ``` -(void) ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event ``` which just like this: ``` self.moveAction = [CCSequence actions: [CCMoveTo actionWithDuration:moveDuration position:touchLocation], [CCCallFunc actionWithTarget:self selector:@selector(guyMoveEnded)], nil ]; ``` but now, I want to auto-invoke a following method by `@selector`: ``` -(void)guyMoveEnded:(BOOL)flag AndWhere:(CGPoint)where Andtime:(float)time{ //do something... } ``` How can I do it? Please help me, I'm confused about the selector. Thanx!

Original source

Related problems