Confusion over this code


#1

I’m a little confused about the reason for including this:

-(void)setAssets:(NSArray *)a
{
_assets = [a mutableCopy];
}

-(NSArray *)assets
{
return [_assets copy];
}

We have already included the ‘copy’ attribute in this property so I thought the copy functionality would already be built into the getter and setter?
@property (nonatomic, copy) NSArray *assets;

If we want to create a copy of assets in the setter then why in the ‘addAsset’ method, do we simply add a pointer to the asset passed as an argument into the assets array and not a copy of this asset?

Greatly appreciated if someone could clear up this confusion with ‘copy’ and ‘strong’.


#2

[quote]We have already included the ‘copy’ attribute in this property so I thought the copy functionality would already be built into the getter and setter?
@property (nonatomic, copy) NSArray *assets;[/quote]
Yes, but how do we specify what kind of copy should be made: mutable or immutable?

Also, mutability/immutability applies only to the container itself, not to its contents.