//// main.m// 归档//// Created by on 14-11-8.// Copyright (c) 2014年 Apple. All rights reserved.//#importint main(int argc, const char * argv[]) { @autoreleasepool { /**********归档***********/ NSArray *array = [[NSArray alloc] initWithObjects:@"abc", @"def", @123, nil]; NSString *filePath = @"/Users/wujiafeng/Desktop/Test.txt"; BOOL success = [NSKeyedArchiver archiveRootObject:array toFile:filePath]; if (success) { NSLog(@"归档成功"); } /**********解归档***********/ NSString *filePath = @"/Users/wujiafeng/Desktop/Test.txt"; // 解归档返回的是id类型,因为我们已经知道归档为NSArray类型,所以就直接用NSArray接收 NSArray *array = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath]; NSLog(@"%@", array); } return 0;}