从原始数组,拆分排列组合成新数组,同时给新的数组中的模型元素追加字段,数组的容量翻倍,如果不用深拷贝,后面追加的值就把前面的值覆盖了

UnitModel *model1 = [UnitModel new];
model1.studyPageId = @""; UnitModel *model2 = [UnitModel new];
model2.studyPageId = @"";
NSArray *modelArr = @[model1,model2];
// 直接调用mutableCopy 并没真的赋值全新的模型数组,需要model遵守NSCopy,NSMutableCopying协议,实现copyWithZone 才能copy出真正的数组
NSMutableArray <UnitModel *>*mutableModelArr = [modelArr mutableCopy];
#pragma mark - 对象深复制,M1TestArrayHelper copy处理
-(id)copyWithZone:(NSZone *)zone {
ImageModel *model = [[self class] allocWithZone:zone];
model.isResult = [_isResult copy];
model.image = [_image copy];
model.text = [_text copy];
model.bgmArr = [_bgmArr copy];
model.coverImageName = [_coverImageName copy];
model.coverCount = [_coverCount copy];
model.errorImageName = [_errorImageName copy];
model.errorImageCount = [_errorImageName copy];
return model;
} -(id)mutableCopyWithZone:(NSZone *)zone {
ImageModel *model = [[self class] allocWithZone:zone];
model.isResult = [_isResult copy];
model.image = [_image copy];
model.text = [_text copy];
model.bgmArr = [_bgmArr copy];
model.coverImageName = [_coverImageName copy];
model.coverCount = [_coverCount copy];
model.errorImageName = [_errorImageName copy];
model.errorImageCount = [_errorImageName copy];
return model;
}

// 这里显示原始数据结构

// 这里显示目标数据结构

04-26 08:39