需要替代 NSURLConnection sendSynchronousRequest
Need alternative of NSURLConnection sendSynchronousRequest
我想同步执行一些任务:
[NSURLConnection sendSynchronousRequest:Request returningResponse:&response error:&error];
已弃用我可以用来代替它的东西。
使用dispatch_sync
同步执行任务。
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
NSLog(@"Required task code.");
dispatch_async(dispatch_get_main_queue(), ^{
// Update UI in main thread.
// Add your UI Label Update code here..
});
});
如果您需要帮助,请告诉我..
使用 "NSURLSession-SynchronousTask" 库产生与 NSURLConnection 相同的结果。
我想同步执行一些任务:
[NSURLConnection sendSynchronousRequest:Request returningResponse:&response error:&error];
已弃用我可以用来代替它的东西。
使用dispatch_sync
同步执行任务。
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
NSLog(@"Required task code.");
dispatch_async(dispatch_get_main_queue(), ^{
// Update UI in main thread.
// Add your UI Label Update code here..
});
});
如果您需要帮助,请告诉我..
使用 "NSURLSession-SynchronousTask" 库产生与 NSURLConnection 相同的结果。