2012-06-28 64 views
0

爲什麼會出現此錯誤?我認爲我已經關閉了所有的括號。這是代碼:消息:預計標識符

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

這不是Smalltalk。布爾運算符*不是*消息發送。 – 2012-06-28 07:32:30

回答

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和不包括他們在[和]