PresentModalViewController: Where to Release?

To use presentModalViewController, I have to allocand initWithNibName:bundle:view. My question is: where can I let him go? Does the dismissModalViewController:animated:release perform?

+3
source share
2 answers

No. If you assigned and initialized it, you must release it. Do it like this:

YourViewController *controller = [[YourViewController alloc] initWithNibName:@"YourView" bundle:nil];
[self presentModalViewController:controller animated:YES];
[controller release];

PresentModalViewController: animated: saveCount is automatically incremented. And as soon as the controller disappears in terms of, it will release the controller. And so the controller will be freed .; -)

+5
source

; ( ) .

+5

Source: https://habr.com/ru/post/1758202/


All Articles