0
在我的应用程序中,我有一个函数updatetimer不断更新计时器。我希望此过程在应用程序处于后台时保持继续。但该方法仅在应用程序处于前台时才会调用。在应用程序处于后台时不会调用该方法.Below是那个代码。我该如何解决这个问题?如何在iphone中使用背景应用程序时运行重复过程?
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
timer=[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTimer) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
[[NSRunLoop currentRunLoop] run];
});
您不必在用户的设备上唯一的应用程序。你必须分享(见下面的答案)。 – borrrden 2012-07-10 06:27:29