【发布时间】:2014-02-20 03:17:09
【问题描述】:
好的,我没有得到关于这个的答案。 :(
Multipeer Connectivity audio streaming stop work on background
这个呢?
我正在尝试在后台运行此代码。
- (void)applicationDidEnterBackground:(UIApplication *)application {
__block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSTimer *aTimer = [NSTimer timerWithTimeInterval:3
target:self
selector:@selector(showInformation)
userInfo:nil
repeats:YES];
[[NSRunLoop mainRunLoop]
addTimer:aTimer
forMode:NSDefaultRunLoopMode];
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
});
}
显然我在同一个范围内定义了这个函数
- (void) showInformation {
NSLog(@"showInformation is called.");
}
但是当我将应用程序放在后台时,间隔消息,停止工作,当我回到前台时继续工作.......
这意味着没有在后台运行?
这可能吗?还是我试图做一些愚蠢的不可能的事情?
非常感谢一些帮助。
非常感谢。
【问题讨论】:
标签: ios objective-c ios7 nstimer multipeer-connectivity