在这里为大家共享一下在开发中遇到的问题,而后又找到了比较不错的答案,虽然是摘抄的,但我相信知识本来就是用来共享的,希望我的这番整理能够给更多的人带来方便。
self.title = @"复杂对象归档";
Person *personA = [[Person alloc] init];
personA.name = @"张三";
personA.age = 20;
personA.sex = @"男";
Person *personB = [[Person alloc] init];
personB.name = @"李四";
personB.age = 15;
personB.sex = @"女";
Person *personC = [[Person alloc] init];
personC.name = @"王五";
personC.age = 30;
personC.sex = @"男";
NSString *paths =[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
NSLog(@"Caches: %@", paths);
NSMutableArray *personsArr = [NSMutableArray arrayWithObjects:personA, personB, personC, nil];
NSString *personsArrPath = [paths stringByAppendingString:@"/personsArr.plist"];
[personsArr writeToFile:personsArrPath atomically:YES];
NSLog(@"%@", personsArrPath);