gpt4 book ai didi

iphone - 比较两个 UITextField

转载 作者:行者123 更新时间:2023-11-28 18:21:48 25 4
gpt4 key购买 nike

我不知道为什么这行不通,我觉得这真的很愚蠢。我正在尝试比较两个文本字段(比如确认密码类型),但它就是行不通!!我尝试了几种不同的选择,但都没有用。我试过:

if (passwordCheckField1.text == passwordCheckField2.text) {
[self performSegueWithIdentifier:@"segue4" sender:nil];
}

我试过:

NSString *retrivedPasswordCheckField1 = passwordCheckField1.text;
NSString *retrivedPasswordCheckField2 = passwordCheckField2.text;
if ([retrivedPasswordCheckField1 isEqualToString:retrivedPasswordCheckField2]) {
[self performSegueWithIdentifier:@"segue4" sender:nil];
}

我试过:

if ([passwordCheckField1.text isEqualToString:retrivedPasswordCheckField2.text]) {
[self performSegueWithIdentifier:@"segue4" sender:nil];
}

我已经实现了 <UITextFieldDelegate>在 .h 中,我还为两个字段设置了代表,( passwordCheckField1.delegate = self;
passwordCheckField2.delegate = self;
)

我错过了什么????感谢您的帮助!

编辑

我可能应该提一下,我正在使用一个带有多个 subview Controller 的导航 Controller 。每个都包含一个文本字段,因此当关于第一个密码的 View Controller 出现时,用户输入它然后单击下一步将它们带到确认密码 View Controller 。所有都链接到相同的类文件。

最佳答案

这应该有效。

NSString *password = passwordCheckField1.text;
NSString *confirmPassword = passwordCheckField2.text;

NSLog(@"password: '%@'", password);
NSLog(@"confirmPassword: '%@'", confirmPassword);

if([password isEqualToString: confirmPassword]) {
NSLog(@"Match");

} else {
NSLog(@"Not Match");

}

关于iphone - 比较两个 UITextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18981662/

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