当Webservice返回字符串数据时,我在Webservice上遇到问题
if ([collectionView indexPathForCell:bookcell ].row == row) {
if ([[[bookList objectAtIndex:row] mainMenu] isEqualToString:@"standard"]) {
// [[bookList objectAtIndex:row] mainMenu]isEqualToString:@"standard"] have 5 row data
}
}
我需要显示NSlog(@"count %d",total)
我如何显示总数= 5通常它会显示count 1
5次,但我需要显示count 5
1次请咨询我。
答案 0 :(得分:1)
我想最简单的事情就是计算数组中“bookList”中有多少个对象具有单词标准。
static int counter = 0; //make this a global variable
for (int i=0; i<[bookList count]; i++)
{
NSString *str1 = [bookList objectAtIndex:i];
if ([str1 isEqualToString:@"standard"])
{
counter++;
}
}
现在你从数组中得到了“标准”字样的总数