Our app has been crashing with a frequency of roughly 1 in 1,500 launches due to a bug that is proving elusive. The relevant portion of the stack trace is included. It\'s
It's likely that UIAlertView is trying to call a method on its delegate after that delegate has been released. To prevent this type of bug, any time you set an object as another object's delegate, set the delegate property to nil in the delegate object's dealloc method. e.g.
@implementation YourViewController
@synthesize yourAlertView;
- (void)dealloc {
yourAlertView.delegate = nil; // Ensures subsequent delegate method calls won't crash
self.yourAlertView = nil; // Releases if @property (retain)
[super dealloc];
}
- (IBAction)someAction {
self.yourAlertView = [[[UIAlertView alloc] initWithTitle:@"Pushed"
message:@"You pushed a button"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil] autorelease];
[self.yourAlertView show];
}
// ...
@end