2012-11-27 20 views

回答

4

首先,我們需要檢查設備是否支持多任務或NOT?

if([UIDevice currentDevice]respondsToSelector:@selector(isMultitaskingSupported)){ 

    // If the device supports Multitasking we can run the task as :- 

    UIBackgroundTaskIdentifier bgTask; 

    bgTask=[[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ 
     [[UIApplication sharedApplication] endBackgroundTask:bgTask]; 
    }]; 

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul), ^{ 
     for(double i=0; i<99999; i++) 
      NSLog(@"Backgroudn quee"); 

     [[UIApplication sharedApplication] endBackgroundTask:bgTask]; 
    }); 
} 
+0

這是答案還是你添加到問題?謝謝 – Fogmeister

+0

它是我想出來的答案 – Zubair

相關問題