sant05
sant05

Reputation: 428

Unable to read WCSession singleton instance of WatchConnectivity framework

I m trying to work on WCSession default instance. But it gives the following complier issue. When I try to read as vairable

When I try to read as method

Compiler suggests as method

Defination of default Instance When I jump to definition

Upvotes: 0

Views: 98

Answers (1)

Zachary Bell
Zachary Bell

Reputation: 610

Try this:

var session : WCSession!

func startSession() {
    if WCSession.isSupported() {
        session = WCSession.default()
        session.delegate = self
        session.activate()
    }
}

Call startSession() wherever you want to activate your WCSession. Preferably in AppDelegate and ExtensionDelegate.

Upvotes: 0

Related Questions