简体   繁体   中英

presentModalViewController memory leak or EXC_BAD_ACCESS

-(void) addBookmarkTapped:(id)sender {
    BookmarkAddViewController *bookmarkAddViewController = 
    [[BookmarkAddViewController alloc] initWithName:currTitle link:self.addressBar.text];
    [self presentModalViewController:bookmarkAddViewController animated:YES];
    [bookmarkAddViewController release];
}                 

code above cause 'EXC_BAD_ACCESS' when back to the main controller. Same error if I make bookmarkAddViewController 'autorelease'.

It will not crash if I remove the release, but it will cause memory leak? [bookmarkAddViewController release];

I see many examples doing the same way, why it doesn't work in my case?

It might have to do with your init method in bookmarkAddViewController .(Please post.) Make sure you dismiss the controller properly with [self dismissModalViewControllerAnimated:YES]; .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM