【问题标题】:How to fix the incompatible block pointer types sending error?如何修复不兼容的块指针类型发送错误?
【发布时间】:2020-07-09 11:19:03
【问题描述】:

由于不兼容的块指针类型在 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];

}

【问题讨论】:

  • 不是最新的 objc 但似乎您尝试将 STPAPIResponseBlock 传递给不匹配的函数参数。 STAPIResponseBlock 可能是专用块的类型别名,getWithApiClient 方法需要 completion 参数的另一种块

标签: ios objective-c swift xcode11


【解决方案1】:

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

你正在发送

STPAPIResponseBlock又名^(ResponseType, NSHTTPURLResponse, NSError)

预期类型是:

^(STPSource, NSHTTPURLResponse, NSError)

STPAPIResponseBlock的第一个参数不兼容。

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

确认您拥有14.0.1 或更高版本的库。这可能会解决问题。

【讨论】:

  • 问题是由于 StripeAPI 因为 Xcode 11 构建成功。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-07
相关资源
最近更新 更多