如何在 performSelector: withObject:afterDelay 的Object里传入多个参数
2014-04-11 11:24
399 查看
写代码的时候可能会遇到如下的问题
一个方法
- (void) fooFirstInput:(NSString*) first secondInput:(NSString*) second
{
}
有两个或者多个参数
当需要执行performSelector方法并且afterDelay的时候,withObject只能传入一个参数,并且也没有对应的withObjects方法,
这么写是不对的。会报错
[self performSelector:@selector(fooFirstInput:secondInput:) withObject:@"first" withObject:@"second" afterDelay:15.0];
遇到这种情况利用如下的一个小方法可以满足调用多个参数的select method
1.
- (void) callFooWithArray: (NSArray *) inputArray
{
[self fooFirstInput: [inputArray objectAtIndex:0] secondInput: [inputArray objectAtIndex:1]];
}
- (void) fooFirstInput:(NSString*) first secondInput:(NSString*) second
{
}
2.
[self performSelector:@selector(callFooWithArray) withObject:[NSArray arrayWithObjects:@"first", @"second", nil] afterDelay:15.0];
一个方法
- (void) fooFirstInput:(NSString*) first secondInput:(NSString*) second
{
}
有两个或者多个参数
当需要执行performSelector方法并且afterDelay的时候,withObject只能传入一个参数,并且也没有对应的withObjects方法,
这么写是不对的。会报错
[self performSelector:@selector(fooFirstInput:secondInput:) withObject:@"first" withObject:@"second" afterDelay:15.0];
遇到这种情况利用如下的一个小方法可以满足调用多个参数的select method
1.
- (void) callFooWithArray: (NSArray *) inputArray
{
[self fooFirstInput: [inputArray objectAtIndex:0] secondInput: [inputArray objectAtIndex:1]];
}
- (void) fooFirstInput:(NSString*) first secondInput:(NSString*) second
{
}
2.
[self performSelector:@selector(callFooWithArray) withObject:[NSArray arrayWithObjects:@"first", @"second", nil] afterDelay:15.0];
相关文章推荐
- 如何在 performSelector: withObject:afterDelay 的Object里传入多个参数
- IOS开发:performSelector: withObject:afterDelay 的Object里传入多个参数
- 如何延迟执行一个block类似performSelector:withObject:afterDelay:?
- performSelector: withObject: afterDelay: 传递基本数据类型参数的bug
- 延迟执行 [self performSelector: withObject: afterDelay: ];
- [self performselector: withObject: afterDelay:];一定时间后执行某个方法
- IOS学习之performSelector:withObject:afterDelay:
- [iOS] performSelector:withObject:afterDelay:调用没有作用的问题及解决方法
- iOS 取消延时执行 performSelector: withObject: afterDelay:
- performSelector:withObject:afterDelay:
- performSelector:withObject:afterDelay: 的用法
- performSelector withObject afterDelay 在子线程上调用不运行
- [iOS] performSelector:withObject:afterDelay:调用没有作用的问题及解决方法
- performSelector withObject afterDelay 在子线程上调用不运行
- performSelector withObject afterDelay 在子线程上调用不运行
- performSelector withObject afterDelay 在子线程上调用不运行
- performSelector:withObject:afterDelay: 精要概览(持续更新)
- [self performSelector:@selector(fun:) withObject:obj afterDelay:2.0];方法是可以在未执行前终止的
- [self performselector: withObject: afterDelay:];一定时间后执行某个方法
- [iOS] performSelector:withObject:afterDelay:调用没有作用的问题及解决方法