そのように作成された配列がある場合:
NSArray* arrItems = [[NSArray alloc] initWithObjects:@"One", @"Two", @"Three", nil];
NSString プロパティを持つクラスがあります。
myClass.myClassString = @"One";
これを行うと、isEqualToString が機能しないはずです。
NSString* strToCheck = myClass.myClassString
for(int i=0; i<arrItems.count; i++) {
NSString* strThisItem = [arrItems objectAtIndex:i];
if ([strThisItem isEqualToString:strToCheck]) {
NSLog(@"Okley dokley!");
}
}
編集:
実際の結果:
私のアプリでも一致が得られません。これは、文字列とその長さの両方を含むログ出力です。Safety Marketing が一致している場所を見てください。ここにも「OK」が記録されているはずです。
2013-08-28 09:20:02.339 oer[3081:c07] ALDAHOL_7::Safety Marketing_16
2013-08-28 09:20:02.341 oer[3081:c07] ALDAHOL_7::Acecide-C Marketing_19
2013-08-28 09:20:02.341 oer[3081:c07] ALDAHOL_7::ALDAHOL Marketing_17
2013-08-28 09:20:02.342 oer[3081:c07] ALDAHOL_7::OER-Pro Service Marketing_25
2013-08-28 09:20:02.342 oer[3081:c07] Acecide-C_9::Safety Marketing_16
2013-08-28 09:20:02.343 oer[3081:c07] Acecide-C_9::Acecide-C Marketing_19
2013-08-28 09:20:02.343 oer[3081:c07] Acecide-C_9::ALDAHOL Marketing_17
2013-08-28 09:20:02.344 oer[3081:c07] Acecide-C_9::OER-Pro Service Marketing_25
2013-08-28 09:20:02.344 oer[3081:c07] Competitor_10::Safety Marketing_16
2013-08-28 09:20:02.345 oer[3081:c07] Competitor_10::Acecide-C Marketing_19
2013-08-28 09:20:02.345 oer[3081:c07] Competitor_10::ALDAHOL Marketing_17
2013-08-28 09:20:02.345 oer[3081:c07] Competitor_10::OER-Pro Service Marketing_25
2013-08-28 09:20:02.346 oer[3081:c07] Safety_Marketing_16::Safety Marketing_16
2013-08-28 09:20:02.346 oer[3081:c07] Safety_Marketing_16::Acecide-C Marketing_19
2013-08-28 09:20:02.347 oer[3081:c07] Safety_Marketing_16::ALDAHOL Marketing_17
2013-08-28 09:20:02.347 oer[3081:c07] Safety_Marketing_16::OER-Pro Service Marketing_25
2013-08-28 09:20:02.348 oer[3081:c07] Acecide-C_Marketing_19::Safety Marketing_16
2013-08-28 09:20:02.348 oer[3081:c07] Acecide-C_Marketing_19::Acecide-C Marketing_19
2013-08-28 09:20:02.349 oer[3081:c07] Acecide-C_Marketing_19::ALDAHOL Marketing_17
2013-08-28 09:20:02.349 oer[3081:c07] Acecide-C_Marketing_19::OER-Pro Service Marketing_25
2013-08-28 09:20:02.350 oer[3081:c07] ALDAHOL_Marketing_17::Safety Marketing_16
2013-08-28 09:20:02.350 oer[3081:c07] ALDAHOL_Marketing_17::Acecide-C Marketing_19
2013-08-28 09:20:02.351 oer[3081:c07] ALDAHOL_Marketing_17::ALDAHOL Marketing_17
2013-08-28 09:20:02.351 oer[3081:c07] ALDAHOL_Marketing_17::OER-Pro Service Marketing_25
2013-08-28 09:20:02.352 oer[3081:c07] OER-Pro Service_Marketing_25::Safety Marketing_16
2013-08-28 09:20:02.352 oer[3081:c07] OER-Pro Service_Marketing_25::Acecide-C Marketing_19
2013-08-28 09:20:02.353 oer[3081:c07] OER-Pro Service_Marketing_25::ALDAHOL Marketing_17
2013-08-28 09:20:02.353 oer[3081:c07] OER-Pro Service_Marketing_25::OER-Pro Service Marketing_25