0

在我的AppDelegate我已经定义

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:达到一次但从不重复。为什么?

4

1 回答 1

2

利用:
self.notificationTimer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(checkForNotifications) userInfo:nil repeats:YES];

于 2013-04-26T21:20:59.233 回答