You already created the arrays in your instance method in BNRPortolio. Just use your 2 lines of NSLog to send the message to BNRPortfolio array (the following assumes you named it portfolio)
[quote]NSLog(@“Top three most valuable holdings are: %@”, portfolio.topThreeHoldings);
NSLog(@“All stocks sorted alphabetically by symbol: %@”, portfolio.allStocksSorted);[/quote]
if ([topThreeStocks count] > 3) {
for (NSUInteger i = [topThreeStocks count]; i > 3; i--) {
[topThreeStocks removeLastObject];
}
}
[/quote]
You actually don’t even need the if statement. It works fine just removing it, but it is a nice check to skip the for loop if the number of holdings you have is already 3 or less.
I’m of the opinion though that to ensure a bug-free line of code (and you are able to), just do away with the line of code completely if its not needed. It makes the code less complicated to read.
So if it was me, I would ditch the if statement, but maybe I’m just lazy.
You already created the arrays in your instance method in BNRPortolio. Just use your 2 lines of NSLog to send the message to BNRPortfolio array (the following assumes you named it portfolio)
[quote]NSLog(@“Top three most valuable holdings are: %@”, portfolio.topThreeHoldings);
NSLog(@“All stocks sorted alphabetically by symbol: %@”, portfolio.allStocksSorted);[/quote][/quote]
I think this only works if you override the description method? If you dont, you just get output like this (at least when I tried this I did):