iOS plist
Posted tongyuling
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS plist相关的知识,希望对你有一定的参考价值。
//存
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);
以上是关于iOS plist的主要内容,如果未能解决你的问题,请参考以下文章