1.序列化和不序列化直接写入文件,前后文件size相差巨大,大约压缩70%。
NSArray * arr = @[@"jhfiwe",@"kuwi",@"oiu",@"jeygri",@"eyriow",@"klwurpwiqh",@"lwurifb",@"lkwurgfuwbc",@"keuhfi",@"klrtgiowv"];
NSArray * doucments = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString * path = [doucments objectAtIndex:0];
//数组直接写入文件
NSString * arryPathUn = [NSString stringWithFormat:@"%@/unxlh.text",path];
[arr writeToFile:arryPathUn atomically:YES];
//序列化后写入
NSString * error;
NSString * xlhPath = [NSString stringWithFormat:@"%@/xlh.text",path];
NSData * data = [NSPropertyListSerialization dataWithPropertyList:arr format:NSPropertyListBinaryFormat_v1_0 options:0 error:&error];
[data writeToFile:xlhPath atomically:YES];