代码
NSString *UserId = [NSString stringWithFormat:@"%ldAAAAAAATTTTTTTT.data", [PKUserInfoTool userInfo].uid];
NSString *PKPostLablePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:UserId];
NSMutableArray *ary = [NSMutableArray array];
for (int i = 0; i < 100; i++) {
[ary addObject:[NSArray arrayWithObjects:[NSString stringWithFormat:@"label%d",i],@"123",@"456", nil]];
}
PKLog(@"pring in ram%@", ary);
//写入数组
[[NSFileManager defaultManager] removeItemAtPath:PKPostLablePath error:nil];
[NSKeyedArchiver archiveRootObject:ary toFile:PKPostLablePath];
//读取数组
ary = nil;
PKLog(@"read from local:%@", ary);
ary = [NSKeyedUnarchiver unarchiveObjectWithFile:PKPostLablePath];
PKLog(@"read from local:%@", ary);
数据内容
016-04-21 15:17:57.338 djcars[5590:140020] pring in ram[
[
label0,
123,
456
],
[
label1,
123,
456
],
[
label2,
123,
456
],
[
label3,
123,
456
],
[
label4,
123,
456
],
[
label5,
123,
456
],
[
label6,
123,
456
],
[
label7,
123,
456
],
[
label8,
123,
456
],
[
label9,
123,
456
]
]