简体   繁体   中英

how to do to wait to load ViewController until appdelegate func application will be completed

I would like to know which is the best way to do the next:

In my AppDelegate.swift file I had the entry point of the app, register the instance, but before the instance is registered, the main function(inside viewDidLoad() ) of the MainViewController is called and I would like to know how to do to wait the MainViewController viewDidLoad() function until the instance register will be completed.

You should add extra view controller and show that view controller initially until your required task got completed. You can show loader or activity indicator or some ui that shows like getting data or etc. After you completed your process move to main viewcontroller so your viewDidload will be called when you want!

ViewDidLoad is Async by design, so is a non-sense waiting for it. When called you are certain UI is up, it was written for this scope. I think is better you read carefully iOS event loop and app lifecycle, to fully undestand Apple design.

您可以使用sleep()函数等待加载viewcontrollers视图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM