Another Take on 2nd Challenge


#1

I used NSArray, not NSMutableArray

[code] BNRStockHolding *h1 = [[BNRStockHolding alloc] init];
[h1 setPurchaseSharePrice:2.30];
[h1 setCurrentSharePrice:4.50];
[h1 setNumberOfShares:40];
BNRStockHolding *h2 = [[BNRStockHolding alloc] init];
[h2 setPurchaseSharePrice:12.19];
[h2 setCurrentSharePrice:10.56];
[h2 setNumberOfShares:90];
BNRStockHolding *h3 = [[BNRStockHolding alloc] init];
[h3 setPurchaseSharePrice:45.10];
[h3 setCurrentSharePrice:49.51];
[h3 setNumberOfShares:210];

    NSArray *holdings = @[h1, h2, h3];
    
    for (BNRStockHolding *h in holdings) {
        NSString *priceString = [NSString localizedStringWithFormat:@"$ %.2f", [h valueInDollars]];
        NSLog(@"Holding Value=%@", priceString);
    }[/code]

One question I have is why do so many of these posts on challenges seem to be in the wrong chapter headings?