NSObject
方法performSelector:withObject:afterDelay:
允许我在一段时间后使用对象参数调用对象上的方法.它不能用于带有非对象参数(例如int、float、structs、非对象指针等)的方法.
使用带有非对象参数的方法来实现同样的目标,有什么方法?我知道对于常规performSelector:withObject:
,解决方案是使用NSInvocation
(顺便说一句,这真的很复杂).但我不知道如何处理"延迟"部分.
谢谢
NSObject
方法performSelector:withObject:afterDelay:
允许我在一段时间后使用对象参数调用对象上的方法.它不能用于带有非对象参数(例如int、float、structs、非对象指针等)的方法.
使用带有非对象参数的方法来实现同样的目标,有什么方法?我知道对于常规performSelector:withObject:
,解决方案是使用NSInvocation
(顺便说一句,这真的很复杂).但我不知道如何处理"延迟"部分.
谢谢
以下是我过go 用NSInvocation无法更改的东西:
SEL theSelector = NSSelectorFromString(@"setOrientation:animated:");
NSInvocation *anInvocation = [NSInvocation
invocationWithMethodSignature:
[MPMoviePlayerController instanceMethodSignatureForSelector:theSelector]];
[anInvocation setSelector:theSelector];
[anInvocation setTarget:theMovie];
UIInterfaceOrientation val = UIInterfaceOrientationPortrait;
BOOL anim = NO;
[anInvocation setArgument:&val atIndex:2];
[anInvocation setArgument:&anim atIndex:3];
[anInvocation performSelector:@selector(invoke) withObject:nil afterDelay:1];