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 に答える