Release or abstract?

Should I use release or autorelease for varSecondViewController?

-(IBAction)takeNextStep: (id) sender
{
    SecondViewController *varSecondViewController = [[SecondViewController alloc]     
       initWithNibName:@"SecondViewController" bundle:nil];
    [self.navigationController pushViewController:varSecondViewController animated:YES];
    [varSecondViewController release];
}
+3
source share
3 answers

My rule:

If you intend to use it, and then no longer need to reference it, release it,

If you transfer it back to the caller (i.e. return it), run it.

+12
source

autorelease - release, , , . , , , - . , . release.

+6

In this case, it releasemakes the most sense.

+4
source

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


All Articles