这里有点混乱。
我将一个类中的一些对象添加到一个数组中。现在我正在尝试遍历这些对象并将它们与所有变量一起打印(到控制台)。
NSArray *stockArray=[NSArray arrayWithObjects:stock1, stock2, stock3, nil];
for (int i=0; i<4; i++)
{
StockHolding *stockItem=[[StockHolding alloc]init];
stockItem=[stockArray objectAtIndex:i];
[print stockItem];
}
我的 Stock Holding 类有几个属性,我在 .h 中声明并在 .m 中与 print 方法一起综合。
但是,当我尝试在上面的代码中使用它来打印“stockItem”时,我收到编译器错误“使用未声明的标识符'print'”
这是没有意义的,因为 Stock Holding 类在 .h 中声明 print 并在 .m 中实现:
-(void) print{
NSLog(@"Current purchase price is %f, current price is %f,
number of shares are %i, cost in dollars is %f, value is dollars is %f",
purchaseSharePrice, currentSharePrice,
numberOfShares, self.costInDollars, self.valueInDollars);
}
我应该使用另一种方式来打印这些数组对象吗?