I’m new to iphone development, and just to get a feel for it, I created a new view which has an alert popup on every load.
This works correctly, however when i shut the app down, then reopen it, the whole app crashes. The only thing I’m doing is showing an alert.
This is my code of the alert:
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: @"Announcement"
message: @"This is really annoying just to make"
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
I think I’m supposed to put [alert release]; but Xcode keeps saying that release is unavailable.
Is the [alert release] the reason my app keeps crashing on exit/restart?
Thanks!
Edit: Heres the surrounding code where I call UIAlertView
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
//just testing alerts..this shows up after the first load only
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: @"Announcement"
message: @"This is really annoying just to make"
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
releasewill be unavailable if you use ARCAlso, It is pretty unusual for a simple alert to cause a crash, as @rdelmar said in the comments, you really need to provide more info about your problem… One thing you could try though is to display your
UIAlertViewinsideviewDidAppearinstead of theviewDidLoadmethod.