Objective C: I have an NSMutableArray with 3 objects of a class stockHolding
the class has a method valueInDollars which returns the product of (numberOfShares * shareMktVlue)
The for loop (below) attempts to dynamically call the method valueInDollars for each element in the Array as follows:
NSUInteger itemCount = [stockHolding count];
for (int i = 0; i < itemCount; i++) {
NSString *itemd = [stockHolding objectAtIndex:i];
float mktValue = [AAPL valueInDollars];
}
The question is: How can AAPL be declared dynamically so that it changes for each loop iteration to the stock symbol object in the array.
I tried to replace AAPL with "itemd" in the code above, but get the error message:
"NSString may not respond to valueInDollars"
Any help here would be appreciated.
StockHoldingobjectsNSLog(@"%@", itemd);afterNSString *itemd = [stockHolding objectAtIndex:i];please.