Xcode 9的Braintree错误
自从升级到Xcode 9后,我的BTAPIClient.m文件中出现了一个新错误 @defaultFirst变量正在触发以下错误: “NSNumber*”类型的对象与字典值不兼容 键入“NSString*” 它发生在以下代码行中:Xcode 9的Braintree错误,braintree,xcode9,Braintree,Xcode9,自从升级到Xcode 9后,我的BTAPIClient.m文件中出现了一个新错误 @defaultFirst变量正在触发以下错误: “NSNumber*”类型的对象与字典值不兼容 键入“NSString*” 它发生在以下代码行中:参数:@{@“default_first”:@(defaultFirst)} 我无法找到记录此错误的其他人。我没有修改任何代码,这是一个新的Cocoapods安装 - (void)fetchPaymentMethodNonces:(BOOL)defaultFirst c
参数:@{@“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);
}
}
});
}];
-(void)fetchPaymentMethodNonces:(BOOL)defaultFirst completion:(void(^)(NSArray*,NSError*)completion{
如果(!self.clientToken){
NSError*error=[NSErrorWithDomain:BTAPIClientErrorDomain代码:BTAPIClienterRotTypeNotAuthorized用户信息:@{NSLocalizedDescriptionKey:@“无法使用令牌化密钥获取支付方法nonce”,NSLocalizedRecoverySuggestionErrorKey:@“此端点需要客户端令牌进行授权”}];
如果(完成){
完成(无,错误);
}
返回;
}
[自助获取:@“v1/付款方式”
参数:@{@“default_first”:@(defaultFirst),
@“session_id”:self.metadata.sessionId}
完成:^(BTJSON*\u可空正文,\u未使用的NSHTTPPURLResponse*\u可空响应,NSError*\u可空错误){
dispatch\u async(dispatch\u get\u main\u queue()^{
如果(完成){
如果(错误){
完成(无,错误);
}否则{
NSMutableArray*paymentMethodNonces=[NSMutableArray];
对于(NSDictionary*paymentInfo在[body[@“paymentMethods”]asArray]中){
BTJSON*paymentInfoJSON=[[BTJSON alloc]initWithValue:paymentInfo];
BTPaymentMethodNonce*paymentMethodNonce=[[BTPaymentMethodNonceParser sharedParser]解析JSON:paymentInfoJSON with ParsingBlockforType:[paymentInfoJSON[@“type”]assString]];
如果(付款方式){
[paymentMethodNonce添加对象:paymentMethodNonce];
}
}
完成(付款方式,无);
}
}
});
}];
我在一个使用Cocoapods的项目中遇到了同样的问题
确保尚未更新依赖项:
- 闭合xcode
- 清除pods文件夹
- 运行
而不是pod安装
更新
- 建造