存入
-(void)writeDic:(NSDictionary*)dic{
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 writeToFile:filename atomically:YES];
//NSDictionary* dic = [NSDictionary dictionaryWithContentsOfFile:plistPath];
}
取出
-(NSDictionary*)dic{
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *path=[paths objectAtIndex:0];
NSLog(@"path = %@",path);
NSString *filename=[path stringByAppendingPathComponent:@"test.plist"];
NSDictionary* dic2 = [NSDictionary dictionaryWithContentsOfFile:filename];
return dic2;
}