布伦特里错误和Xcode 9

问题描述:

我得到我的BTAPIClient.m文件一个新的错误,因为我升级到Xcode的9布伦特里错误和Xcode 9

的@defaultFirst变量触发以下错误:

对象键入'NSNumber *'与字典值 类型'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
  • 明确舱体文件夹
  • 运行pod install不是update
  • 构建
+0

谢谢!我还联系了Braintree,他们能够复制错误并承诺尽快发布修复 –