0

我有这段代码:

    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,is 语句总是转到 else。有人可以告诉我我做错了什么吗?

tnx 提前。

4

1 回答 1

2

您想用来[email.text isEqualToString:emailComfirm.text]比较 2 个 NSString* 对象的内容。使用 == 将比较 2 个对象的地址,而不是对象的内容。这就是指针的工作原理指向指针的指针如何在 C 中工作?

于 2012-09-18T19:25:16.563 回答