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];
}
}
这包含图像和数据。我需要将图像存储到缓存中。
答案 0 :(得分:0)
请使用SDWebImage它包含您需要的一切。我已经使用这个库已经2年了。
遵循该教程,其中包含如何使用简单的一行代码缓存UIImageView中的图像,以及预览背景中所有图像的类,只需创建一个包含您要预取的所有图像的NSArray。
希望有所帮助!