用UITextFieldsearch标签文本
我有一个UILabel和一个UITextField。 每当用户在字段中input文本时,我需要检查标签文本中存在的文本字段文本(基本上我正在search标签的文本)。 我正在使用
NSRange range = [sentenceRequestLabel.text rangeOfString:resultString]; if (range.location == NSNotFound) { NSLog(@"string was found"); } else { NSLog(@"string was not found"); }
检查(resultString是textfield.text),但即使文本字段中的标签文本甚至不接近标签的文本NSLog说“findstring”。 任何想法有什么不对?
if (range.location == NSNotFound) { NSLog(@"string was found");
意思是“如果找不到string,就打印出来”。 那==
应该是!=
。