casparjespersen
casparjespersen

Reputation: 3840

NSTimer selector not repeating

In my AppDelegate I have defined

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];
}

The checkForNotifications: is reached once but never repeated. Why?

Upvotes: 0

Views: 361

Answers (1)

Dan Shelly
Dan Shelly

Reputation: 6011

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

Upvotes: 2

Related Questions