Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当应用程序进入iphone的背景时,如何在中对任务进行计数_Iphone_Objective C_Ios5_Ios4_Ios6 - Fatal编程技术网

当应用程序进入iphone的背景时,如何在中对任务进行计数

当应用程序进入iphone的背景时,如何在中对任务进行计数,iphone,objective-c,ios5,ios4,ios6,Iphone,Objective C,Ios5,Ios4,Ios6,即使应用程序在iPhone iOS中退出活动状态时进入后台,我如何运行任务直到任务完成。首先,我们需要检查设备是否支持多任务处理 if([UIDevice currentDevice]respondsToSelector:@selector(isMultitaskingSupported)){ // If the device supports Multitasking we can run the task as :- UIBackgroundTaskIdentifier b

即使应用程序在iPhone iOS中退出活动状态时进入后台,我如何运行任务直到任务完成。

首先,我们需要检查设备是否支持多任务处理

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];
    });
}

首先,我们需要检查设备是否支持多任务处理

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];
    });
}

这是答案还是你在补充问题?谢谢我找到的答案,这是答案还是你在补充问题?谢谢我找到的答案