繁体   English   中英

每10分钟重复执行一次动作

[英]Repeatedly fire an action every 10 minutes

我想在每10分钟使用一次应用程序后执行一次操作。

我想每10分钟显示一次全屏广告,而不管该应用程序的ViewController当前在哪里。

您需要使用NSTimer并设置timeInterval = 10repeats = YES并将此计时器声明为didFinishLaunchingWithOptions方法。 有关更多信息,您可以阅读NSTimer官方文档。

还要看看我如何使用NSTimer?

尝试这个 :

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

希望它会有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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