I want to pass an NSInteger argument to a method called using performSelector:WithObject:afterDelay, so I have this code:
id arg = [NSNumber numberWithInt:myIdentifier];
[self performSelector:@selector(myMethod:) withObject:arg afterDelay:kDuration];
- (void) myMethod: (id) identifier
{
...
}
Within myMethod:, how do I convert the identifier from an id to an NSInteger?
I’ve seen this previous question:
SEL performSelector and arguments
but I don’t understand myMethodForNumber: – how is that used to unbox the number?
myMethodcan accept theNSNumberas the parameter. You can then get the integer value by using theNSNumberinstance method.