self.title=@"复杂对象归档";Person*personA=[[Personalloc]init];personA.name=@"张三";personA.age=20;personA.sex=@"男";Person*personB=[[Personalloc]init];personB.name=@"李四";personB.age=15;personB.sex=@"女";Person*personC=[[Personalloc]init];personC.name=@"王五";personC.age=30;personC.sex=@"男";NSString*paths=[NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES)firstObject];NSLog(@"Caches:%@",paths);NSMutableArray*personsArr=[NSMutableArrayarrayWithObjects:personA,personB,personC,nil];NSString*personsArrPath=[pathsstringByAppendingString:@"/personsArr.plist"];[personsArrwriteToFile:personsArrPathatomically:YES];NSLog(@"%@",personsArrPath);代码如上,我想要归档一个Model数组,应该如何编写?
当年话下
相关分类