我从Web服务器加载图像文件,然后将其保存到nsuserdefaults。保存代码大致是:保存/重新加载图像并删除旧图像
NSData *imageData = UIImagePNGRepresentation(theImage); // theImage is a UIImage
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:imageData forKey:string]; // string is a 3-dig number which identifies image
现在,显然我在错误的脚已经,因为不推荐用于图像NSUserDefaults的..
但我想要做的是保存在某个地方这些图像,因此无需重新下载即可访问它们。此外,我想删除旧图像(假设一天过去,或只保留最近10次下载的图像)?有这个好技术吗?
是否有一个在UITableView中使用的ASIHTTPRequest缓存图像的工作示例? – cannyboy 2011-05-20 11:35:33