I have a problem. It looks like ARC synchronizes my property with child class.
Here’s the code
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"tableView:didSelectRow: %i", indexPath.row);
JobDetailViewController *jdViewController=[[JobDetailViewController alloc] initWithNibName:@"JobDetailViewController" bundle:nil];
jdViewController.delegate=self;
[jdViewController setJob:[[jobsWithPipes objectAtIndex:indexPath.row] job]];
[self.navigationController pushViewController:jdViewController animated:YES];
}
The problem is that jdViewController's job property synchronizes with [[jobsWithPipes objectAtIndex:indexpath.row] job]. All properties are nonatomic, retain.
When I’m changing the NSNumber* foreman property in jdViewController the new value copies to parent view controller. Why? It looks like ARC uses copy instead of retain on this objects. Help me please
I think your understanding of
retainandcopyis backwards.With a
retainproperty, when you assign a value to it, it gets a pointer to the same object that you assigned. So if you modify one object, it modifies the other.With a
copyproperty, when you assign a v alue to it, it gets a copy of the object. So the objects will be identical, but distinct. When you modify one object, it won`t modify the other.