rootViewController 是否总是准备好在 application:didBecomeActive 被调用(iOS)时呈现一个 segue?

Is rootViewController always ready to present a segue by the time application:didBecomeActive is called (iOS)?

我的应用程序在故事板中设置了 rootViewController。这个问题我本来是问的,现在才知道是问错了:

Is the viewDidLoad method of the rootViewController always called before application:didBecomeActive in the app delegate? Does that viewDidLoad method always finish before application:didBecomeActive is called, or can the two run concurrently?

I can run tests, but I know that these tests don't take into account every situation. I want to understand if there are hard and fast rules that apply here, or if I might possibly be dealing with race conditions at some point. From what I can tell, viewDidLoad of the rootViewController seems to be called and finished before application:didbecomeActive is called, but I can't figure out if this is something I can rely on.

I am using iOS 11 and Xcode 9.

我的 rootViewController 用于显示我的 appUpdating 视图、密码视图、我的法律条款视图、我的 handleImportedFile 视图和我的 tabbarcontroller。它就像某种启动协调器,因为我的加载过程非常复杂。现在我正在移动用户的sqlite数据库的位置,我的一些用户的数据库很大。它必须在后台完成,但是当 hud 在主队列中 运行 时,因为在完成之前应用程序无法显示数据。如果我在 application:didFinishLaunchingWithOptions 期间执行此操作,一些用户将获得看门狗定时器。所以我想将加载过程移动到 application:didBecomeActive(我有一个标志告诉我应用程序是否正在从终止启动)。完成后 运行,rootViewController 执行到相关视图的 segue。但我认为 rootViewController 需要在那个时候加载,我不确定情况是否总是如此。

基本上,在下面的代码中,我试图弄清楚 [self.masterController showApplicableView] 是否会导致 rootViewController(我称之为 masterController)执行 segue,是否在 'safe place' 中被调用,或者,如果在 any 情况下,此时让 rootViewController 执行 segue 可能为时过早。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    self.masterController = (MasterViewController*)self.window.rootViewController;
    self.activatingFromTerminated = YES;

    return YES;
}

- (void)applicationWillEnterForeground:(UIApplication *)application {

    self.activatingFromTerminated = NO;
}

- (void)applicationDidBecomeActive:(UIApplication *)application {

    if (_activatingFromTerminated) {

        self.activatingFromTerminated = NO;

        [[CoreDataController sharedManager] loadStoreWithCompletionHandler:^(NSError * _Nullable error) {

            if ([CoreDataController sharedManager].storeLoaded) {

                [self.masterController showApplicableView];//performs applicable segue
            }
        }];
    }
}

From what I can tell, viewDidLoad of the rootViewController seems to be called and finished before application:didbecomeActive is called, but I can't figure out if this is something I can rely on.

不是,你也不应该。你根本不应该担心这个。事实上,您认为您需要知道这是代码中的难闻气味。这些是来自两个完全不同区域(应用程序和视图控制器)的生命周期事件,它们的相对时间与您无关。在每个事件中做适合该事件意义的事情。