如何修复不兼容的块指针类型发送错误?

How to fix the incompatible block pointer types sending error?

由于 xcode 11.5 中不兼容的块指针类型发送错误,构建失败。

- (NSURLSessionDataTask *)retrieveSourceWithId:(NSString *)identifier 
    clientSecret:(NSString *)secret 
    responseCompletion:(STPAPIResponseBlock)completion {
    NSString *endpoint = [NSString stringWithFormat:@"%@/%@", 
        APIEndpointSources, identifier];
    NSDictionary *parameters = @{@"client_secret": secret};
    return [STPAPIRequest<STPSource *> getWithAPIClient:self

                                           endpoint:endpoint

                                         parameters:parameters

                                       deserializer:[STPSource new]

                                         completion:completion];

}

观察错误中描述的两种类型块之间的差异。

您正在发送

STPAPIResponseBlock 又名 ^(ResponseType, NSHTTPURLResponse, NSError)

预期类型是:

^(STPSource, NSHTTPURLResponse, NSError)

STPAPIResponseBlock 的第一个参数不兼容。

不过看起来这可能是 bug in the Stripe API

确认您拥有 14.0.1 或更高版本的图书馆。 可能 解决问题。