Milo
Milo

Reputation: 5091

Alert View issues after popping view controller

I have a stack that looks like this: Navigation Controller -> Table View Controller -> Another Table View Controller.

Whats happening is that in a method in AnotherTableViewController I show an alert view, and then pop the controller off the stack. The alert view displays fine, except that after clicking the dismiss button, it throws an EXC_BAD_ACCESS which I know is what happens when you send a message to a released object. What I think is happening is that the alert view is sending the dismissWithClickedButtonAtIndex:Animated: message to the delegate which I had assigned to AnotherTableViewController but it got released after I popped it so now after the message is sent, it throws the error. How should I go about showing an alert view after popping the controller (or right before)?

I also am using properties in AnotherTableViewController and displaying them in my alert view.

Upvotes: 0

Views: 553

Answers (1)

2intor
2intor

Reputation: 1044

While showing UIAlertView you should not set the delegate like below,

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Please enter current and new password" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

as you are not doing anything on the delegate methods this solution should work

Upvotes: 3

Related Questions