标签:
//存
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *path=[paths objectAtIndex:0];
NSLog(@"path = %@",path);
NSString *filename=[path stringByAppendingPathComponent:@"test.plist"];
NSFileManager* fm = [NSFileManager defaultManager];
[fm createFileAtPath:filename contents:nil attributes:nil];
//创建一个dic,写到plist文件里
NSDictionary* dic = @{@"image":str};
NSLog(@"dic----%@",dic);
[dic writeToFile:filename atomically:YES];
//取
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *path=[paths objectAtIndex:0];
NSString *filename=[path stringByAppendingPathComponent:@"test.plist"];
NSDictionary* dic2 = [NSDictionary dictionaryWithContentsOfFile:filename];
NSLog(@"dic2---%@",dic2);
标签:
原文地址:http://www.cnblogs.com/tongyuling/p/5534278.html