AM newbiee to iPhone. I wanna to get the specific attributes in JSON output. Below is the JSON output: My requirement is to show "RATES" with corresponding Country codes in UIPicker. Could anyone help me please.
{
"license": "License Agreement available at: http://openexchangerates.org/license/",
"timestamp": 1361260808,
"base": "USD",
"rates": {
"AED": 3.67274,
"AFN": 51.9082,
"ALL": 104.737376,
"AMD": 406.549996,
"ANG": 1.788975,
"AOA": 95.945867,
"ARS": 5.011293,
"AUD": 0.9682,
"AWG": 1.7901,
"AZN": 0.7847
}
}
这只是一个字典,从rates键中获取数组中的所有值,然后使用该数组加载选择器视图。
NSData *data = [yourjsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError*error;
NSDictionary *responseDict;
responseDict = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
NSLog(@"%@",[responseDict valueForKey:@"rates"]);
NSLog(@"%@",[[responseDict valueForKey:@"rates"] valueForKey:@"AED"]);
NSLog(@"%@",[responseDict valueForKey:@"timestamp"]);
it will help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.