这里的代码不多,但这个问题让我很恼火!
。H:
@interface processController : UIViewController {
NSTimer *timer;
}
@property (nonatomic, retain) NSTimer *timer;
米:
- (void)viewDidLoad {
[super viewDidLoad];
timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector (main) userInfo:nil repeats:YES];
}
- (void)main {
NSLog(@"testing");
}
- (void)viewDidUnload {
[self.timer invalidate];
self.timer = nil;
}
奇怪的是,当我触发这段代码时:
ViewController *main = [[ViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:main animated:YES];
并切换视图,计时器不断触发!我究竟做错了什么?