获取程序中无需释放的ViewController

AppDelegate.h

@property (strong, nonatomic) UIViewController *viewController;

 

在需要用的地方

#define appDelegate ((AppDelegate *)[UIApplication sharedApplication].delegate)

 if (!appDelegate.viewController) {

        appDelegate.viewController =[ [UIViewController alloc]init]

    }

    [self presentViewController:appDelegate.viewController animated:YES completion:^{

    }];

原文地址:https://www.cnblogs.com/joesen/p/4744376.html