Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
maytelabargamalaga
Courses Plus Student 6,465 PointsUIAlertView multiple
I am creating an AlertView that let to user reset the password. Evething goes fine but when I try to write an AlertView that say the user " your email is not found" this AlertView is not appear. Only appear the first AlertView that I wrote.
I really really appreciate is someone can tell what is wrong in this code.
Thanks in advance
''''
-
(IBAction)forgotPassword:(id)sender {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Direccion de Correo" message:@"Introduzca su correo electronico:" delegate:self cancelButtonTitle:@"Cancelar" otherButtonTitles:@"Aceptar", nil]; alertView.alertViewStyle = UIAlertViewStylePlainTextInput; [alertView show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex ==1) { UITextField *emailTextField = [alertView textFieldAtIndex:0];
PFQuery *query = [PFUser query];
[query whereKey:@"email" equalTo:self.emailTextField.text];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
if (objects.count ==0) {
[self sendEmail:emailTextField.text];
UIAlertView *alertView =[[UIAlertView alloc]initWithTitle:@"Correo enviado" message:@"Por favor, revise su correo para resetear su contraseƱa" delegate:self cancelButtonTitle:@"Cancelar" otherButtonTitles:nil];
[alertView show];
if (objects == nil){
UIAlertView *alertView =[[UIAlertView alloc]initWithTitle:@"Correo no encontrado" message:@"Por favor, introduzca un correo electronico valido" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Aceptar", nil];
[alertView show];
}
}
} else {
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
}
}
-
(void)sendEmail:(NSString *)email {
[PFUser requestPasswordResetForEmailInBackground:email];
}
'''''
2 Answers
Stephen Whitfield
16,771 PointsBoth conditionals mean the same thing. Maybe you should revise your first conditional to check and see if there are any objects rather than there not being any.
maytelabargamalaga
Courses Plus Student 6,465 PointsCan you write an example how can I make different meaning in the conditional ? I will really appreciate it. Thank indeed