// NSDictionary * dict=[[NSDictionary alloc]initWithObjectsAndKeys:@"one",@"1",@"two",@"2",@"three" ,@"3",nil]; // //只能在特定的路径下写文件 // [dict writeToFile:PATH atomically:YES]; //归档 NSArray * array=[[NSArray alloc]initWithObjects:@"one",@"two",@"three", nil]; NSDictionary * dict=[[NSDictionary alloc]initWithObjectsAndKeys:@"one",@"1",@"two",@"2",@"three" ,@"3", nil]; NSMutableData * data=[[NSMutableData alloc]init]; NSKeyedArchiver * archiver=[[NSKeyedArchiver alloc]initForWritingWithMutableData:data]; [archiver encodeObject:array forKey:@"array"]; [archiver encodeObject:dict forKey:@"dict"]; [archiver finishEncoding]; [data writeToFile:PATH atomically:YES]; //解档 NSData * data1=[[NSData alloc]initWithContentsOfFile:PATH]; NSKeyedUnarchiver * unarchiver=[[NSKeyedUnarchiver alloc]initForReadingWithData:data1]; NSArray * array1=[unarchiver decodeObjectForKey:@"array"]; NSLog(@"%@",array1);