my solution to sort by symbol
ZGCPortfolio.h - declared new method
- (NSArray *)getHoldings; // return array of holdings sorted by stock symbol
ZGCPortfolio.m - implemented method
[code]- (NSArray *)getHoldings
{
NSSortDescriptor *sym = [NSSortDescriptor sortDescriptorWithKey:@“symbol” ascending:YES];
[_holdings sortUsingDescriptors:@[sym]];
return self.holdings;
// or use return [_holdings sortedArrayUsingDescriptors:@[sym]];
}[/code]
main.m
NSLog(@"My Holdings: %@", [myPortfolio getHoldings]);
[color=#0000FF]OUTPUT
2014-10-31 17:55:35.703 ObjC_Classes_ZGCPortfolio_Stocks_Challenge[3606:116486] My Holdings: (
“You paid $92.00USD for 40 shares of APPL, now valued at $180.00USD”,
“You paid $1097.10USD for 90 shares of BNNE, now valued at $1400.40USD”,
“You paid $112.50USD for 10 shares of CHPN, now valued at $225.00USD”,
“You paid $37.50USD for 10 shares of UKLN, now valued at $150.00USD”[/color]