Search code examples
iphoneobjective-cperformselector

Performselector - argument 2 makes pointer from integer without cast


I have this code:

[self performSelector:@selector(animationWithType:) withObject:PasscodeAnimationTypeConfirm afterDelay:0.2];

To this method:

-(void)animationWithType:(PasscodeAnimationType)type;

Putting this in it's place:

[self performSelector:@selector(animationWithType:) withObject:[NSNumber numberWithInt:PasscodeAnimationTypeConfirm] afterDelay:0.2];

returns an NSLog of "1", which my method doesn't class as the same value as PasscodeAnimationTypeConfirm. How can i fix this?


Solution

  • Yeah, as far as I know, you can only do performSelector:blahBlah:withDelay: with objects as parameters, not types (ints, chars, etc.).

    You can create another function to help you, like this:

    -(void)animationWithNumber:(NSNumber)type{
        [self animationWithType:[NSNumber intValue]];
    }
    

    And using this one from the code you posted:

    [self performSelector:@selector(animationWithType:) withObject:[NSNumber numberWithInt:PasscodeAnimationTypeConfirm] afterDelay:0.2];