for (Annotation *ann in annotaionArray) // annotationArray contains annotations added to map
{
NSString *fetchedtitle = ann.title;
if([fetchedtitle isEqualToString:oldTitle]); // oldTitle = textfield.text
{
ann.title = appDelegate.pinTitle;
break;
}
}
但是比较总是正确的。请问可能是什么错误?
从sqlite获取的const char被转换为
stringWithUTF8String
。一切都已完成,可以完美地转换为字符串,但是为什么比较时仍然出错?
最佳答案
删除尾随的分号!
if ([fetchedtitle isEqualToString:oldTitle])
{
ann.title = appDelegate.pinTitle;
break;
}
使用分号,您的代码与以下代码相同:
if ([fetchedtitle isEqualToString:oldTitle])
;
{
ann.title = appDelegate.pinTitle;
break;
}
关于objective-c - isEqualToString始终返回true,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14958125/