我有班级one.m,在班级one.m中定义了NSTimer
myTimer = [NSTimer scheduledTimerWithTimeInterval:2.6
target:self
selector:@selector(updateView:)
userInfo:nil
repeats:YES];
如何在mainviewcontroller中访问此NSTimer以暂停和恢复它。
答案 0 :(得分:0)
您可以将计时器作为属性,然后从MainViewController
类访问它。
就像这样
@interface One: UIDelegate {
//variables
}
@property(nonatomic, retain) NSTimer* myTimer;
@implementation One
@synthesize myTimer;
//other
@implementation MainViewController
One *one = [[One alloc]init];
one.myTimer; //now you can access the timer