为什么会出现这个错误?我认为我关闭了所有括号。这是代码:
int i=0;
while(i<count){
if([[ageMatch rangeOfString:age].location != NSNotFound] && [[glassesSex rangeOfString:gender].location !=NSNotFound] && [[faceMatch rangeOfString:shape].location != NSNotFound] ){ //Expected identifier
[arrayNuovo insertObject:dictionary atIndex:i];
}
i++;
}
答案 0 :(得分:2)
你应该改变
if([[ageMatch rangeOfString:age].location != NSNotFound] && [[glassesSex rangeOfString:gender].location !=NSNotFound] && [[faceMatch rangeOfString:shape].location != NSNotFound] )
要
if([ageMatch rangeOfString:age].location != NSNotFound &&
[glassesSex rangeOfString:gender].location !=NSNotFound &&
[faceMatch rangeOfString:shape].location != NSNotFound )
当你进行布尔测试时,你会像[string rangeOfString:age].location != NSNotFound
那样进行,并且不要将它们包括在[和]中
答案 1 :(得分:0)
使用此代码
while(i < count){ if(([ageMatch rangeOfString:age].location != NSNotFound) && ([glassesSex rangeOfString:gender].location !=NSNotFound) && ([faceMatch rangeOfString:shape].location != NSNotFound) ){ //Expected identifier [arrayNuovo insertObject:dictionary atIndex:i]; } i++; }