gpt4 book ai didi

iphone - sendAsynchronousRequest NSURLConnectionRequest

转载 作者:行者123 更新时间:2023-11-29 04:08:44 25 4
gpt4 key购买 nike

在下面的方法中,如果我在completionHandler中进行数据处理,是否会阻塞主线程?换句话说,completionHandler 中执行的任何操作是在主线程上完成还是在后台线程上完成?

+ (void)sendAsynchronousRequest:(NSURLRequest *)request
queue:(NSOperationQueue*) queue
completionHandler:(void (^)(NSURLResponse*, NSData*, NSError*)) handler NS_AVAILABLE(10_7, 5_0);

最佳答案

the documentation队列是:

The operation queue to which the handler block is dispatched when the request completes or failed.

因此handler将在那里执行。值得注意的是,无论哪种方式都没有 promise 实际的 URL 连接内容将在哪里完成,因此如果您想在主线程上完成,您应该只指定 [NSOperationQueue mainQueue]

关于iphone - sendAsynchronousRequest NSURLConnectionRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14763050/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com