Objective c 在NSTimer中将对象传递给方法
这真是个愚蠢的问题。如何使用NSTimer将对象传递给方法? 我的意思是这样的- 我在Objective c 在NSTimer中将对象传递给方法,objective-c,nstimer,Objective C,Nstimer,这真是个愚蠢的问题。如何使用NSTimer将对象传递给方法? 我的意思是这样的- 我在BigView.m中有一个方法,它有一个名为doSomethingWithClass:的方法 - (void)doSomethingWithClass:(CustomClass *)class { NSLog(@"Something was done"); } 在另一个名为CustomClass的类中,我有一个NSTimer- NSTimer *timer = [NSTimer scheduledTi
BigView.m
中有一个方法,它有一个名为doSomethingWithClass:
的方法
- (void)doSomethingWithClass:(CustomClass *)class {
NSLog(@"Something was done");
}
在另一个名为CustomClass
的类中,我有一个NSTimer-
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:bigView selector:@selector(doSomethingWithClass:) userInfo:nil repeats:NO];
其中bigView是bigView的一个实例。现在我想在方法
doSomethingWithClass:
中传递CustomClass的整个实例作为参数。如何操作?如果不需要参考计时器,请使用更简单的
(要取消它,)如果不需要参考计时器,请使用更简单的 (要取消它,)
[bigView performSelector:@selector(doSomethingWithClass:)
withObject:customClass
afterDelay:0.5];