NSString *path =[[NSBundle mainBundle] pathForResource:@“movielist” ofType:@“txt”];
NSMutableDictionary *dic =[NSJSONSerialization JSONObjectWithData:data option:NSJSONReadingMutableContainers error:nil];
NSMutableArray *movieArr =[NSMutableArray array];
for (NSMutableDictionary *temp in dic[@"result"]) {
Movie *movie =[[Movie alloc] init];
[movie setValuesForKeysWithDictionary:temp];
[movieArr addObject:movie];
[movie release];
}
NSString *strURL =@"http://api.map.baidu.com/place/v2/search?query=银行®ion=大连&output=json&ak=6E823f587c95f0148c19993539b99295";
NSString *strEncode= [strURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url =[NSURL URLWithString:strEncode];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
三个参数:第一个参数是刚刚创建的请求,第二个是返回的一个响应,第三个是错误信息
NSURLResponse *response = nil;
NSError *error =nil;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
把所有的银行名都打印出来
原代码:
NSMutableDictionary *dic =[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
for (NSDictionary *dic1 in dic[@"results"]) {
NSLog(@"%@",dic1[@"name"]);
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文:http://blog.csdn.net/mltianya/article/details/47731907