1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
//将图片保存到本地 + ( void )SaveImageToLocal:(UIImage*)image Keys:(NSString*)key { NSUserDefaults* preferences = [NSUserDefaults standardUserDefaults]; //[preferences persistentDomainForName:LocalPath]; [preferences setObject:UIImagePNGRepresentation(image) forKey:key]; } //本地是否有相关图片 + (BOOL)LocalHaveImage:(NSString*)key { NSUserDefaults* preferences = [NSUserDefaults standardUserDefaults]; //[preferences persistentDomainForName:LocalPath]; NSData* imageData = [preferences objectForKey:key]; if (imageData) { return YES; } return NO; } //从本地获取图片 + (UIImage*)GetImageFromLocal:(NSString*)key { NSUserDefaults* preferences = [NSUserDefaults standardUserDefaults]; //[preferences persistentDomainForName:LocalPath]; NSData* imageData = [preferences objectForKey:key]; UIImage* image; if (imageData) { image = [UIImage imageWithData:imageData]; } else { NSLog(@ "未从本地获得图片" ); } return image; } |
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持服务器之家!
原文链接:http://www.cnblogs.com/jukaiit/p/6605030.html