@triunion the approach taken here is to control access to the properties. In this case the
@property *assets has public access, but the
_assets variable is private, meaning that it can’t be accessed outside of itself. We are using the default setter / getter on the
@property *assets to set our private property, and to return an immutable copy of the array instead of a direct reference to the array itself. This ensure that no other object is able to modify that array except for the BNREmployee class after it has been set. We are using mutableCopy / copy to alter the mutability here, so when it is set, we are converting the array so that it can be modified internally, and when someone gets the value, we are making it immutable, implying in the code that we don’t want outside objects to make modifications. Now obviously, someone could convert that back to a mutable array, but because it is a copy, it will not effect the assets property inside of the BNREmployee object.
BNREmployee * employee = [[BNREmployee alloc] init];
employee.assets = @[@"asset 1", @"asset 2"];
NSMutableArray * assets = [employee.assets mutableCopy];
[assets addObject: @"asset 3"];
NSLog(employee.assets); //["asset 1", "asset 2"]
NSLog(assets); //["asset 1", "asset 2", "asset 3"]
Does all of that make sense?