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 performselector:@selector(tabledata:) withObject:y afterDelay:0.1];
Method execution is here
-(int)tabledata:(int)cellnumber {
NSLog(@"cellnumber: %@",cellnumber);
idLabel.text = [NSString stringWithFormat:@"Order Id: %@",[[records objectAtIndex:cellnumber] objectAtIndex:0]];
}
but I am not getting exact integer value in my method, I am only getting the id value.
A selector is an identifier which represents the name of a method. It is not related to any specific class or method, and can be used to describe a method of any class, whether it is a class or instance method. Simply, a selector is like a key in a dictionary.
The solution to your problem is to pass the object that should run the selector method along with the selector to the initialisation of the ValueAnimator object. Also update the timerCallback() : @objc func timerCallback() { ... _ = target.
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];
Instead of your performSelector:withObject:afterDelay:, use an NSTimer, thusly:
int y = 0;
[NSTimer scheduledTimerWithTimeInterval:0.1 repeats:NO block:^(NSTimer *timer) {
[self tabledata:y];
}];
You can pass whatever you want in the timer block.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With