出于某种原因,我无法分配从可变数组中检索的对象
更新:请注意,我正在使用 ARC
这是代码:
id<Control> control = [formControlUtils getControlWithId:@"123"];
// Here control.controlValue is "Old value"
control.controlValue = @"New value";
// Even after assigning a new value to the property the value is still "Old value"
- (id<Control>)getControlWithId:(NSString *)controlId {
id<Control> control = nil;
for (NSArray *array in [FormRenderManager sharedInstance].formControls)
{
//[FormRenderManager sharedInstance].formControls is a mutable array, so is the nested arrays
control = [[array filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"controlId = %@", controlId]] lastObject];
if (control)
break;
}
return control;
}
正如您在我上面的代码注释中看到的那样,每当为 control.controlValue 分配一个新值时,旧值仍然存在。
这是为什么?我可能在这里错过了一些基本的东西,还是因为我违反了协议<id>Control control
?