So in a watchOS app, you will have an WKExtensionDelegate, and an initial WKInterfaceController run on start.
The WKInterfaceController will have its Awake method run, to which passes a 'context' parameter.
public partial class InitialInterfaceController : WKInterfaceController { protected InitialInterfaceController(IntPtr handle) : base(handle) {} public override void Awake(NSObject context) // where does this come from? { base.Awake(context); } }
Now I'm aware any subsequent WKInterfaceController can get a context from the previous WKInterfaceController such as calling
PresentController("SecondInterfaceController", "secondContext");
but I'm unsure how one might set data to the first or if it is even possible.
So is it possible, how?
This context is set for passing parameters. When we use PresentController
and PushController
to show a new interface controller, we can use this context.
But if it is the root controller, why do we need to set that? It's a global api for using, there's no need to consume that for each controller. Just use it when you need to do that.
Answers
This context is set for passing parameters. When we use
PresentController
andPushController
to show a new interface controller, we can use this context.But if it is the root controller, why do we need to set that? It's a global api for using, there's no need to consume that for each controller. Just use it when you need to do that.
I thought it might be possible to do something in the WKExtensionDelegate, which is apparently executed only once before the root controller, and then pass the result to the root controller...
And this because i was having trouble executing code in the constructor of the root controller.
Surely I'm doing something illegal in the constructor, but there is no report of error during debugging.
if I can't figure it out ill post again later.
thanks for chiming in.