gpt4 book ai didi

objective-c - 如何在UITextField中查找特定文本?

转载 作者:行者123 更新时间:2023-12-01 17:42:46 25 4
gpt4 key购买 nike

在我的iPhone应用程序中,我有一个UITextField ans文本字段值被放入了NSString中,我想查找是否在其中键入了特定字符 "

我怎样才能做到这一点?

UITextField *textField;
NSString *String=textField.text;

-(IBAction)FindCharecter:(id)sender
{
// if String Contain ",then i wish to print @"Found symbol"
}

最佳答案

 UITextField *textField;
NSString *string=textField.text;
if ([string rangeOfString:@"\""].location == NSNotFound) {
NSLog(@"string does not \"");
} else {
NSLog(@"string contains \"");
}

检查一下

关于objective-c - 如何在UITextField中查找特定文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14109007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com