NSKeyedArchiver基础用法

NSKeyedArchiver
========================================================*/
NSString *str = @”abc”;
NSString *astr = @”efg”;
NSArray *Array = [NSArray arrayWithObjects:str, astr, nil];

//保存数据
NSString *Path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];

NSString *filename = [Path stringByAppendingPathComponent:@"test"];
[NSKeyedArchiver archiveRootObject:Array toFile:filename];

str = @”a”;
astr = @”";

//加载数据
NSArray *arr = [NSKeyedUnarchiver unarchiveObjectWithFile: filename];
str = [arr objectAtIndex:0];
astr =  [arr objectAtIndex:1];

NSLog(@”str:%@”,str);
NSLog(@”astr:%@”,astr);

 

 

http://linwwwei.iteye.com/blog/1069420

你可能感兴趣的:(Path)