how can i pass an int value through a selector method?

后端 未结 3 1801
孤城傲影
孤城傲影 2020-12-15 09:34

I want to pass an int value from my selector method, but the selector method takes only an object type parameter.

int y =0;
[self performselecto         


        
3条回答
  •  温柔的废话
    2020-12-15 10:07

    The easiest solution, if you 'own' the target selector, is to wrap the int argument in an NSNumber:

    -(int)tabledata:(NSNumber *)_cellnumber {
        int cellnumber = [_cellnumber intValue];
        ....
    }
    

    To call this method you would use:

    [self performselector:@selector(tabledata:) withObject:[NSNumber numberWithInt:y] afterDelay:0.1];
    

提交回复
热议问题