本文介绍了iPhone:performSelector with BOOL参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在选择器中发送BOOL?
Is there any way to send BOOL in selector ?
[self performSelector:@selector(doSomething:) withObject:YES afterDelay:1.5];
或者我应该使用NSInvocation?有人可以写样品吗?
Or I should use NSInvocation ? Could somebody write a sample please ?
推荐答案
你可以用NSNumber来包装bools类型:
you can use NSNumber to wrap bools types:
BOOL myBool = YES;
NSNumber *passedValue = [NSNumber numberWithBool:myBool];
[self performSelector:@selector(doSomething:) withObject:passedValue afterDelay:1.5];
并且在选择器中,要获得bool值,请使用:
and in the selector, to get the bool value, you use:
BOOL value = [recievedObject boolValue];
这篇关于iPhone:performSelector with BOOL参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!