textfield文本内容比较无法正常工作 [英] textfield text content comparision wont work
本文介绍了textfield文本内容比较无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这段代码:
if (email.text == emailComfirm.text) {
UIAlertView *emailAllertView = [[UIAlertView alloc] initWithTitle:@"Succes" message:@"Yaaay, je kan nu gebuik gaan maken van Vogelspotter." delegate:self cancelButtonTitle:@"Direct aanmelden" otherButtonTitles: nil];
[emailAllertView show];
// Doing some other code here
[self dismissModalViewControllerAnimated:YES];
}else{
NSLog(@"email: %@", email.text);
NSLog(@"email: %@", emailComfirm.text);
UIAlertView *emailAllertView = [[UIAlertView alloc] initWithTitle:@"Foutmelding" message:@"De opgegeven email adressen komen niet met alkaar overeen" delegate:self cancelButtonTitle:@"Probeer het nog eens" otherButtonTitles: nil];
[emailAllertView show];
}
不知何故,如果我输入ee/ee或ee/ff,则我不会在文本字段中键入"moather wath",该语句始终转到其他语句.有人可以告诉我我在做什么错吗?
somehow, no moather wath i type in the textfiels, the is statment always goes to the else, if i enter ee/ee or ee/ff. Can someone tell me what i'm doing wrong?
tnx.
推荐答案
您要使用[email.text isEqualToString:emailComfirm.text]
比较2个NSString *对象的内容.使用==将比较两个对象的地址,而不是对象的内容.这就是指针的工作方式如何在C中使用指针?
You want to use [email.text isEqualToString:emailComfirm.text]
to compare the contents of 2 NSString* objects. using == will compare the addresses of the 2 objects, not the contents of the objects. This is how pointers work How do pointer to pointers work in C?
这篇关于textfield文本内容比较无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文