I'm trying to pass an integer (testInt) through the userInfo field of NSTimer
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(count:) userInfo:testInt repeats:YES];
However I'm getting an incompatible types error message.
Does anyone know how to pass a number through to the count method?
You need to box it to an NSNumber:
timer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(count:)
userInfo:@(testInt) // <-- @() around your int.
repeats:YES];
Then in -count:
int testInt = [timer.userInfo intValue];
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