Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set rootInterfaceController in Apple Watch's "ExtensionDelegate"

I am making a Apple Watch app and I'd like to set different root view controllers, depending on an initial condition.

I cannot set the WatchKit rootInterfaceController directly though, because it is a readonly property, but by checking Apple documentation, they say it is possible to set it "before the launch sequence finishes".

Do you have a good suggestion to do that? Maybe through the storyboard?

like image 932
marcelosalloum Avatar asked May 30 '16 12:05

marcelosalloum


1 Answers

You can't set read only property, you can do something like,

Create some SplashController, with some splash screen, and in awakeWithContext

 override func awakeWithContext(context: AnyObject?) {
      super.awakeWithContext(context)
 }

track something that you need, after track present some controllers, for example

   if !isCounting {
    self.presentControllerWithName("Interface", context: nil)
} else {
    self.presentControllerWithName("Timer", context: nil)
}

isCounting is stored in NSUserDefaults

hope this will help :)

like image 87
Ketan Parmar Avatar answered Oct 22 '22 18:10

Ketan Parmar