Potential leak of the selected object - UIViewController

My application is a view-based application. I have 3 view managers. (Main, sub, detail) Each viewcontroller has one UIView. MainViewcontroller has a subView start button. the method is as follows.

- (IBAction) LaunchSubView: (id) sender {

subViewcontroller *viewController = [[subViewcontroller alloc] init];

UIView *currentView = self.view;
[UIView transitionFromView:currentView 
                    toView:viewController.view 
                  duration:0.5 
                   options:UIViewAnimationOptionTransitionFlipFromLeft   
                completion:^(BOOL finished){}];

}

While I am trying to build and analyze, I received this warning. Potential diversion allocated in line 54 and stored in the 'viewController' I tried [viewController release] after perehodaFromView method and subViewcontroller * viewController = [[[[ subViewcontroller alloc] init] autorelease]; in both cases, the cause of the application crash. any idea what should i do? Thanks in advance for any help. =)

+3
source share
2 answers

transitionFromView:toView:duration:options:completion:- the wrong way to use. You should probably use presentModalViewController:animated:.

If you read the documentation for transitionFromView:toView:duration:options:completion:, it explains:

. . , , , . "

+1

subViewcontroller *viewController = [[subViewcontroller alloc] initWithNibName:@"name of you nib file" bundle:@"if you have a bundle otherwise nil"]

viewController

[subViewcontroller release];

0

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


All Articles