これは 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";
};
};
その Paypal アダプティブ ペイメントから。私はこれをやってしまった:
- (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];
}
辞書の辞書の辞書からそのキーを取得するより効率的な方法はありますか? 本当に必要なのはその鍵だけです。だから私は他のものを循環したりループしたりすべきだとは思いませんでした。