标签:
//NSUserDeafult保存图片数据到本地
-(void)saveImage:(UIImage *)image{
NSData* data=[NSKeyedArchiver archivedDataWithRootObject:image];
[[NSUserDefaults standardUserDefaults] setObject:data forKey:@"xxxx"];数据保存到本地的Key
}
//读取NSUserDeafult保存到班底的图片数据
-(UIImage *)headImage{
NSData* data = [[NSUserDefaults standardUserDefaults] objectForKey:@"xxxx"];
id image= [NSKeyedUnarchiver unarchiveObjectWithData:data];
NSLog(@"image!:%@",image);
if(image){
return image;
}
return [UIImage imageNamed:@"YYYY"]本地没有读取到就返回默认图片
}
标签:
原文地址:http://www.cnblogs.com/paocai2015/p/5076005.html