1
这是一个NSDictionary的输出:如何循环查看本词典?
从贝宝自适应支付{
client = {
environment = mock;
"paypal_sdk_version" = "1.0.3";
platform = iOS;
"product_name" = "PayPal iOS SDK";
};
payment = {
amount = "39.95";
"currency_code" = USD;
"short_description" = "Awesome saws";
};
"proof_of_payment" = {
"adaptive_payment" = {
"app_id" = "APP-1245783590";
"pay_key" = "AP-70M62356425642W";
"payment_exec_status" = COMPLETED;
timestamp = "2012-03-03T15:53:55Z";
};
};
及其。最后我做这个:
- (void)verifyCompletedPayment:(PayPalPayment *)completedPayment {
NSDictionary *pOPDictionary = [NSDictionary dictionaryWithDictionary:completedPayment.confirmation];
NSLog(@"pOPDictionary: %@",pOPDictionary);
NSDictionary *subDictionary = [pOPDictionary objectForKey:@"proof_of_payment"];
NSDictionary *sub2Dictionary = [subDictionary objectForKey:@"adaptive_payment"];
NSString *proofString = [sub2Dictionary objectForKey:@"payment_exec_status"];
if ([proofString isEqualToString:@"COMPLETED"]) {
NSLog(@"Payment Completed Successfully");
} else {
NSLog(@"Payment Error");
}
NSData *confirmation = [NSJSONSerialization dataWithJSONObject:completedPayment.confirmation options:0 error:nil];
}
是否有更有效的方式来获得从字典词典的字典中的键?我只是真的需要那个钥匙。所以我不认为我应该循环或循环通过其他人。