Taha Munir
Taha Munir

Reputation: 153

Getting instance of Extension Delegate in WatchKit InterfaceController

I am trying to get the instance of ExtensionDelegate in InterfaceController in Apple Watch application but can't seem to find a way. I have created a method in Extension Delegate that I need to call and for that I would need a shared instance of Extension Delegate. Is there a way to do so?

Like for iOS App, we call it like:

[(AppDelegate *)[[UIApplication sharedApplication] delegate] methodName];

Upvotes: 0

Views: 387

Answers (2)

Use below code to get the same

ExtensionDelegate* myDelegate = (ExtensionDelegate*)[[WKExtension sharedExtension] delegate];

Upvotes: 1

Antonioni
Antonioni

Reputation: 578

You can reference the ExtensionDelegate with the line below. Be sure to import WatchKit.

#import <WatchKit/WatchKit.h>

ExtensionDelegate* myDelegate = (ExtensionDelegate*)[[WKExtension sharedExtension] delegate];
[myDelegate methodName];

Upvotes: 1

Related Questions