多线程在ios开发中的做用,常用的多线程类和方法有哪些.

2025-05-05 08:51:01
推荐回答(1个)
回答1:

#define kBgQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) //1

dispatch_async(kSystemAppUpdateQueue, ^{

NSError *error;

NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]

options:0

error:&error];

if (error!=nil) {

NSLog(@"%@",error.description);

[self performSelectorOnMainThread:selectorError withObject:nil waitUntilDone:YES];

}

else{

if (data!=nil)

{

[self performSelectorOnMainThread:selectorDone withObject:data waitUntilDone:YES];

}

else

{

[self performSelectorOnMainThread:selectorError withObject:nil waitUntilDone:YES];

}

}

});

return;