的NSTimer选择不重复
问题描述:
在我AppDelegate
我已经定义的NSTimer选择不重复
AppDelegate.h
@property (strong, nonatomic) NSTimer *notificationTimer;
AppDelegate.m
@synthesize notificationTimer = _notificationTimer;
- (void)applicationDidBecomeActive:(UIApplication *)application {
NSLog(@"applicationDidBecomeActive");
self.notificationTimer = [NSTimer timerWithTimeInterval:5
target:self
selector:@selector(checkForNotifications:)
userInfo:nil
repeats:YES];
[self.notificationTimer fire];
}
达到的checkForNotifications:
一次,但绝不重复。为什么?
答
使用:self.notificationTimer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(checkForNotifications) userInfo:nil repeats:YES];
我想通了这一点我已经张贴了这个问题的时刻。谢谢,不过。 – 2013-04-26 21:39:55