Как передать объект JSON с API в iOS
https://api.coinbase.com/v1/transactions/send_money
передать ниже параметр с этим API.
{
"transaction": {
"to": "user1@example.com",
"amount": "1.234",
"notes": "Sample transaction for you"
}
}
2 ответа
Решение
Я получил это и..
NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
[dic setObject:@"user1@example.com" forKey:@"to"];
[dic setObject:@"1.234" forKey:@"amount"];
[dic setObject:@"sending money" forKey:@"notes"];
NSMutableDictionary *dic1 = [NSMutableDictionary dictionaryWithObjectsAndKeys:dic,@"transaction", nil];
Вот полный пример использования iOS SDK от Coinbase:
NSDictionary *transactionDict = @{
@"to": @"user1@example.com",
@"amount": @"1.234",
@"notes": @"sending money" };
NSDictionary *params = @{ @"transaction": transactionDict };
[apiClient doPost:@"transactions/send_money" params:transactionDict completion:^(id result, NSError *error) {
if (error) {
NSLog(@"Could not send money: %@", error);
} else {
NSLog(@"Success: %@", [result objectForKey:@"transaction"]);
}
}];