Xcode 9 的 Braintree 错误

标签 braintree xcode9

自从我升级到 Xcode 9 后,我的 BTAPIClient.m 文件中出现了一个新错误。

@defaultFirst 变量触发以下错误:

Object of type 'NSNumber *' is not compatible with dictionary value type 'NSString *' .



它发生在以下代码行中:parameters:@{@"default_first": @(defaultFirst)}
我无法找到记录此错误的其他人。我没有修改任何代码,这是一个新的 Cocoapods 安装。
- (void)fetchPaymentMethodNonces:(BOOL)defaultFirst completion:(void (^)(NSArray <BTPaymentMethodNonce *> *, NSError *))completion {
if (!self.clientToken) {
NSError *error = [NSError errorWithDomain:BTAPIClientErrorDomain code:BTAPIClientErrorTypeNotAuthorized userInfo:@{ NSLocalizedDescriptionKey : @"Cannot fetch payment method nonces with a tokenization key", NSLocalizedRecoverySuggestionErrorKey : @"This endpoint requires a client token for authorization"}];
    if (completion) {
        completion(nil, error);
    }
    return;
}

[self GET:@"v1/payment_methods"
         parameters:@{@"default_first": @(defaultFirst),
                      @"session_id": self.metadata.sessionId}
         completion:^(BTJSON * _Nullable body, __unused NSHTTPURLResponse * _Nullable response, NSError * _Nullable error) {
             dispatch_async(dispatch_get_main_queue(), ^{
                 if (completion) {
                     if (error) {
                         completion(nil, error);
                     } else {
                         NSMutableArray *paymentMethodNonces = [NSMutableArray array];
                         for (NSDictionary *paymentInfo in [body[@"paymentMethods"] asArray]) {
                             BTJSON *paymentInfoJSON = [[BTJSON alloc] initWithValue:paymentInfo];
                             BTPaymentMethodNonce *paymentMethodNonce = [[BTPaymentMethodNonceParser sharedParser] parseJSON:paymentInfoJSON withParsingBlockForType:[paymentInfoJSON[@"type"] asString]];
                             if (paymentMethodNonce) {
                                 [paymentMethodNonces addObject:paymentMethodNonce];
                             }
                         }
                         completion(paymentMethodNonces, nil);
                     }
                 }
             });
}];

最佳答案

我在使用 Cocoapods 的项目中遇到了同样的问题。

确保你没有更新你的依赖项:

  • 关闭 xcode
  • 清除 pods 文件夹
  • 运行 pod install不是 update
  • 构建
  • 关于Xcode 9 的 Braintree 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46382149/

    相关文章:

    UINavigationBar 后退按钮未在 iPhone X iOS 11 上显示

    ios - 在 iPhone X 模拟器的顶部和底部看到黑条

    javascript - 尝试将 Braintree 嵌套回调转换为 NodeJS 异步/等待语法

    php - PHP 中的 Braintree API - 强制交易货币

    ruby-on-rails - Webmock:如何伪造 gzipped 响应?

    swift - Xcode 无法识别新的测试函数

    swift4 - swift4 迁移后 DocumentReadingOptionKey 键损坏

    app-store-connect - 从 App Store Connect 下载 dSYM 文件未按预期工作

    javascript - sails +布伦特里 : Unable to send the transactions details to client

    python - 模板语法错误 : No module named braintree in paypal template?