【发布时间】:2016-09-27 23:03:22
【问题描述】:
NSURL *url =[NSURL URLWithString:
@"http://api.kivaws.org/v1/loans/search.json?status=fundraising"];
序列化部分在下面完成
(void)connectionDidFinishLoading{
NSDictionary *allDict = [NSJSONSerialization JSONObjectWithData:webData options:0 error:nil];
NSArray *loans = [allDict objectForKey:@"loans"];
countryArray = [[NSMutableArray alloc] init];
for (NSDictionary *diction in loans) {
Country *countryObj = [[Country alloc]init];
NSString *sector = [diction objectForKey:@"sector"];
countryObj.sector = sector;
NSDictionary *imageID = [diction objectForKey:@"image"];
NSString *img = [imageID objectForKey:@"id"];
countryObj.idValue=img;
NSString *activity = [diction objectForKey:@"activity"];
countryObj.activity = activity;
NSString *name = [diction objectForKey:@"name"];
countryObj.name = name;
NSDictionary *con = [diction objectForKey:@"location"];
NSString *world = [con objectForKey:@"country"];
countryObj.country= world;
NSString *towname = [con objectForKey:@"town"];
countryObj.down=towname;
[countryArray addObject:countryObj];
}
}
这包含图像和数据。我需要将图像存储到缓存中。
【问题讨论】:
-
用户 SDWebimage 或 AFN 用于异步加载图像
-
这是一个请求 API,您需要首先将请求发送到服务器,然后需要按照 nitin gohel 注释对响应进行 serlize 处理
-
我已经完成了序列化并将其加载到 tableview 中。但事情是每次从 url 加载都需要时间。因为我比较新鲜,所以我不知道 SDWebimage/AFN
-
你能展示你尝试过的代码吗
-
请往上看,我已经添加了一些序列化代码
标签: ios objective-c ios7 ios5