如果我有一个这样创建的数组:
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!");
}
}
编辑:
真实世界的结果:
在我的应用程序中,我什至没有得到匹配 - 这是我的日志输出,包含字符串及其长度 - 查看安全营销匹配的位置 - 这里也应该记录一个“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