NSArray 和 NSMutableArray 相互转换:
// NSArray --> NSMutableArray NSMutableArray *myMutableArray = [myArray mutableCopy]; // NSMutableArray --> NSArray NSArray *myArray = [myMutableArray copy];
数据中有 null,无法存储
writeToFile写入不成功的原因
[cacheDic writeToFile:cacheURL atomically:YES]; 后却返回no,查阅手册发现: If an array or dictionary contains objects that are not property-list objects, then you cannot save and restore the hierarchy of data using the various property-list methods and functions.
也就说要存的不能为你自定义的对象,也不能是null,我就是服务器返回的数据字典中有null,结果存了半天不行,可是自己写了个字典就能保存,后来才找到原因,发现服务器返回的数据中竟然有个null,坑人啊
Swift 判断是否为NULL:
if data is NSNull {
}