I don't directly see why your code isn't working, as there is no [NSArray alloc]
in the code you posted, so it must be somewhere else.
- (void)holdings:(NSArray *)a
{
_holdings = [a mutableCopy];
}
- (NSArray *)setHoldings
{
return [_holdings copy];
}
these really need to change to
- (void)setHoldings:(NSArray *)a
{
_holdings = [a mutableCopy];
}
- (NSArray *)holdings
{
return [_holdings copy];
}
I have no idea what would even happen with the code portfolio.holdings = [mutable copy];
It would call [portfolio setHoldings:[mutable copy]]
, but you currently have no method called setHoldings
that takes a parameter. Because of the dot syntax, I suspect it just calls [portfolio setHoldings]
and sets the copy of the _holdings
array to the value [mutable copy]
which would then do nothing because of the return of the array being a copy.