Are AFNetworking success/failure blocks invoked on the main thread?

后端 未结 4 868
南方客
南方客 2020-12-04 23:44

Does AFNetworking call the completion block on the main thread? or is it called in the background, requiring me to manually dispatch my UI updates to the main thread?

<
4条回答
  •  没有蜡笔的小新
    2020-12-05 00:08

    In AFNetworking 2, AFHTTPRequestOperationManager has a completionQueue property.

    The dispatch queue for the completionBlock of request operations. If NULL (default), the main queue is used.

        #if OS_OBJECT_USE_OBJC
        @property (nonatomic, strong, nullable) dispatch_queue_t completionQueue;
        #else
        @property (nonatomic, assign, nullable) dispatch_queue_t completionQueue;
        #endif
    

    In AFNetworking 3, the completionQueue property has been moved to AFURLSessionManager (which AFHTTPSessionManager extends).

    The dispatch queue for completionBlock. If NULL (default), the main queue is used.

    @property (nonatomic, strong) dispatch_queue_t completionQueue;
    @property (nonatomic, strong, nullable) dispatch_queue_t completionQueue;
    

提交回复
热议问题