How to change alert message when error occured aft

2020-05-07 07:52发布

I would like to change the error message that comes with the alert, when an error occur when the user signs in.
I tried with :

- (void)signUpViewController:(PFSignUpViewController *)signUpController didFailToSignUpWithError:(NSError *)error {
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"me" message:error.debugDescription preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
    [alert addAction:ok];
    [self presentViewController:alert animated:YES completion:nil];
    NSLog(@"Failed to sign up... %@ ", error.debugDescription);

}

the log appears well, but the alert controller is still the old one. For the record, when the email is already taken, it says "the email MyName ..." instead of "the email MyEmail... is already taken".

Would you know how to do this?

Edit :
enter image description here

2条回答
对你真心纯属浪费
2楼-- · 2020-05-07 08:23

the message is error.debugDescription. if you want, you can change it to something else, whatever you want

查看更多
做自己的国王
3楼-- · 2020-05-07 08:32

Paul, my email address is showing up in place of the MyName, you have something else going on there.

Additionally, I have been playing around with this for 1.6 and found the same results as this answer 2 years ago and an updated comment from another Parse developer here 1 year ago. I guess they just don't find it a priority for us right now. This doesn't make my answer right, someone else may have found a solution, but I subclassed the signUpViewController and everything where you have access to self.signUpView.emailField.text to pass in your UIAlertController. Also, nothing is in their changelog about it. So my answer, is, it's not directly editable at this time, but don't feel like it's the right answer. It simply looks like if you want this functionality you will have to go with either localized strings or creating your own sign up /login view controllers where you have access to the UITextFields text and where you can use whatever alert you wish, custom or otherwise

查看更多
登录 后发表回答