简体   繁体   中英

Repeatedly fire an action every 10 minutes

I want to fire an action after every 10 minutes of application use.

I want to display a full screen advertisement after every 10 minutes, irrespective of where ViewController of the application is currently at.

You need to use NSTimer with set the timeInterval = 10 and repeats = YES and declare this timer to your didFinishLaunchingWithOptions method. For more information you can read this official documentation of NSTimer .

And also look at How do I use NSTimer?

Try this :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        timer = [NSTimer scheduledTimerWithTimeInterval:600 target:self selector:@selector(doAction) userInfo:nil repeats:YES ];
        [pool release];
}

Hope it will help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM