Is there any way to send a BOOL
in selector ?
[self performSelector:@selector(doSomething:) withObject:YES afterDelay:1.5];
Or I should use NSInvocation
? Could somebody write a sample please ?
In the case that you cannot alter the target-method signature to accept a NSNumber
in place of a BOOL
you can use NSInvocation
instead of performSelector
:
MyTargetClass* myTargetObject;
BOOL myBoolValue = YES; // or NO
NSMethodSignature* signature = [[myTargetObject class] instanceMethodSignatureForSelector: @selector( myMethodTakingBool: )];
NSInvocation* invocation = [NSInvocation invocationWithMethodSignature: signature];
[invocation setTarget: myTargetObject];
[invocation setSelector: @selector( myMethodTakingBool: ) ];
[invocation setArgument: &myBoolValue atIndex: 2];
[invocation invoke];