Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法让我检测文本字段中是否有某个字符(,),如果有,显示和提醒?我没有任何代码,因为我真的不知道从哪里开始:)。非常感谢!
如果您有一个文本字段并且想要获取它的值,请使用以下命令:
NSString *myString = textField.text;
现在您可以检查是否myString包含它:
myString
if ([myString rangeOfString:@","].location == NSNotFound) { NSLog(@"Not found!"); } else { NSLog(@"Display and Alert!"); }