For some reason I am unable to assign an object which I retrieve from a mutable array
UPDATE: Note that I'm using ARC
Here is the code:
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;
}
As you can see in my code comments above, whenever a assign a new value to control.controlValue the old value still persists.
Why is that? Do I perhaps miss something fundamental here or is it due to the fact that I work against a protocol <id>Control control
?