请求更多的后台时间

 1 - (void)applicationDidEnterBackgtound
 2 {
 3     UIApplication *app = [UIApplication sharedApplication];
 4     __block UIBackgroundTaskIdentifier taskId;
 5     
 6     taskId = [app beginBackgroundTaskWithExpirationHandler:^{
 7         NSLog(@"%@",NSStringFromSelector(_cmd));
 8         [app endBackgroundTask:taskId];
 9     }];
10     
11     if (taskId == UIBackgroundTaskInvalid) {
12         return;
13     }
14     
15     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
16         //做一些额外的操作
17         [app endBackgroundTask:taskId];
18     });
19 }

 

posted @ 2014-12-29 11:54  糊涂人  阅读(304)  评论(0编辑  收藏  举报