- 博客(0)
- 资源 (1)
空空如也
io后台运行demo
-(id) init
{
self = [super init];
if(self)
{
bgTask = UIBackgroundTaskInvalid;
expirationHandler =nil;
timer =nil;
}
return self;
}
-(void) startBackgroundTasks:(NSInteger)time_ target:(id)target_ selector:(SEL)selector_
{
timerInterval =time_;
target = target_;
selector = selector_;
[self initBackgroudTask];
//minimum 600 sec
[[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:^{
[self initBackgroudTask];
}];
}
-(void) initBackgroudTask
{
dispatch_async(dispatch_get_main_queue(), ^(void)
{
if([self running])
[self stopAudio];
while([self running])
{
[NSThread sleepForTimeInterval:10]; //wait for finish
}
[self playAudio];
});
}
2015-06-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人