//如果指定的路径下面没有文件,系统hi创建一个文件,如果有,删除; 重新添加 NSFileManager *filemanager = [NSFileManager defaultManager]; if ([filemanager fileExistsAtPath:[self filePath]]) { NSError *err; [filemanager removeItemAtPath:[self filePath] error:&err]; } NSData *data_ = [NSKeyedArchiver archivedDataWithRootObject:imagearr]; [filemanager createFileAtPath:[self filePath] contents:data_ attributes:NULL];//读取NSSArry NSFileManager *f = [NSFileManager defaultManager];//NSFileManager 对目录进行管理,对文件进行管理 if ([f fileExistsAtPath:[self filePath]]) { NSData *data_ = [NSData dataWithContentsOfFile:[self filePath]]; //NSMutableArray *arr = [NSMutableArray arrayWithContentsOfFile:[self filePath]]; NSMutableArray *arr = [NSKeyedUnarchiver unarchiveObjectWithData:data_]; } //文件路径- (NSString *)filePath{ //document路径 NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; //具体文件路径 NSString *path = [docPath stringByAppendingPathComponent:@"Myimages"];//zifu字符串拼接 return path;}