페이지

2020년 1월 14일 화요일

Add InitViewController

In App executing at first time, app sometimes have lots of tasks.


  • splash view showing
  • check app version
  • load app significant values from UserStandard or local storage
  • showing app usage info popup view ( it's a one-off )
  • locked screen for log-in
  • and so on
  • splash view hiding


class AppDelegate: UIResponder, UIApplicationDelegate {
    var window :UIWindow?
    var naviController :UINavigationController?
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        naviController = window?.rootViewController as? UINavigationController ;
        showSplash()
    }

    func showSplash(){
        let vc = UIViewController.instantiateViewController(storyboard: "Sotryboard", viewController: "\(InitViewController.self)" )
        window?.rootViewController = vc;
    }

}





class InitViewController: UIViewController{
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        checkInit()
    }


    func checkInit(){
        Async.serial(tasks: [
        {  done in
            task1 {
                done(nil)
            }
        }
        ,
        { done in
            task2 {
                done(nil)
            }
        }
        ,
        { done in
            //chage rootViewController.
            UIApplication.appDelegate?.window?.rootViewController = UIApplication.appDelegate?.naviController
            self.dismiss(animated: true, completion: {
                    done(nil)
            })
        }

    }

}



댓글 없음:

댓글 쓰기