Ios 如何从字符串检查计数
当Webservice返回字符串数据时,我在Webservice上遇到了问题Ios 如何从字符串检查计数,ios,uicollectionview,uicollectionviewcell,Ios,Uicollectionview,Uicollectionviewcell,当Webservice返回字符串数据时,我在Webservice上遇到了问题 if ([collectionView indexPathForCell:bookcell ].row == row) { if ([[[bookList objectAtIndex:row] mainMenu] isEqualToString:@"standard"]) { // [[bookList objectAtIndex:row] mainMenu]isEqualToString:@"standard"]
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)
我如何显示total=5通常它会显示count 1
5次,但我需要显示count 5
1次请告诉我。我想最简单的事情是计算数组“bookList”中有多少个对象包含单词standard
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++;
}
}
静态整数计数器=0//将其设为全局变量
对于(int i=0;我在这里看不到total
变量。此外,我不知道您如何期望值为1
的东西登录为5
。您必须大幅改进此问题。。。