Iphone 在标签字符串中显示NSMutableArray大小

Iphone 在标签字符串中显示NSMutableArray大小,iphone,ios,nsmutablearray,return,Iphone,Ios,Nsmutablearray,Return,当屏幕第一次加载时,我试图在主屏幕上的标签中显示NSMutableArray的大小,然后每次我点击Add按钮时,都会出现错误,例如“Expression result unused”。我尝试了几种选择,但仍然没有成功。。。 请告知我您的意见,谢谢!:) 而不是 self.lblCarsCount.text = @"%d cars in the race", &arraySize; // this is the problematic line 您应该使用: self.lbl

当屏幕第一次加载时,我试图在主屏幕上的标签中显示
NSMutableArray
的大小,然后每次我点击Add按钮时,都会出现错误,例如“Expression result unused”。我尝试了几种选择,但仍然没有成功。。。 请告知我您的意见,谢谢!:)

而不是

self.lblCarsCount.text = @"%d cars in the race", &arraySize; // this is the problematic line      
您应该使用:

self.lblCarsCount.text = [NSString stringWithFormat: @"%d cars in the race", [arrRaceCars count]]

第一行代码可以编译,但编译器不知道您想要使用一种格式的字符串(“表达式结果未使用警告”),这就是为什么您应该在其中放入显式“
stringWithFormat
”方法调用的原因。

我稍微重写了您的代码,由于请求是使用
numberOfObjectsInArray
方法-
self.lblCarsCount.text=[NSString stringWithFormat:@“%d辆赛车”,因此[self numberOfObjectsInArray:arrRaceCars]适当披露:我们与Bandooki在这个项目上合作。非常感谢你的帮助!现在它工作得很好!我会确保他稍后会接受你的回答!:)
self.lblCarsCount.text = [NSString stringWithFormat: @"%d cars in the race", [arrRaceCars count]]