我有这段代码:
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,我就不会在textfiels中键入moather wath,如果我输入ee / ee或ee / ff,那么该语句总是会传给其他人。有人能告诉我我做错了吗?
提前tnx。答案 0 :(得分:2)
您想使用[email.text isEqualToString:emailComfirm.text]
来比较2个NSString *对象的内容。使用==将比较2个对象的地址,而不是对象的内容。这就是指针的工作方式How do pointer to pointers work in C?