Use main queue when dispatch queue is not specified

pull/20560/head
Muxi Yan 5 years ago
parent 48d0d6f5ad
commit c754c0389c
  1. 2
      src/objective-c/ProtoRPC/ProtoRPC.h
  2. 6
      src/objective-c/ProtoRPC/ProtoRPC.m

@ -84,7 +84,7 @@ NS_ASSUME_NONNULL_BEGIN
* should be issued.
*/
- (nullable instancetype)initWithResponseHandler:(void (^)(GPBMessage *, NSError *))handler
responseDispatchQueue:(dispatch_queue_t)responseDispatchQueue;
responseDispatchQueue:(nullable dispatch_queue_t)responseDispatchQueue;
/** Response headers received during the call. */
@property(readonly, nullable) NSDictionary *responseHeaders;

@ -38,7 +38,11 @@
responseDispatchQueue:(dispatch_queue_t)dispatchQueue {
if ((self = [super init])) {
_responseHandler = handler;
_responseDispatchQueue = dispatchQueue;
if (dispatchQueue == nil) {
_responseDispatchQueue = dispatchQueue;
} else {
_responseDispatchQueue = dispatch_get_main_queue();
}
}
return self;
}

Loading…
Cancel
Save