Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type 'UIViewController' does not conform to protocol 'WCSessionDelegate'

Since upgrading on Xcode 8 (Beta 1) and Swift 3 I have an error in this line:

class CloudViewController: UIViewController, WCSessionDelegate {

It says :

Type 'UIViewController' does not conform to protocol 'WCSessionDelegate'

This is my (with Xcode 7 and Swift 2 working) code:

override func viewDidLoad() {
    super.viewDidLoad()

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

func session(_ session: WCSession, didReceiveMessage message: [String : AnyObject]) {

    print("didReceiveMessage")

    watchMessageHandler.getMessage(message)

}

This error also shows up in the WKInterfaceController classes.

like image 676
Devhess Avatar asked Nov 29 '22 14:11

Devhess


1 Answers

With Swift 3, you should implement this methods according to the new protocol

session:activationDidCompleteWithState:error:

sessionDidBecomeInactive:

sessionDidDeactivate:

because they are not marked as optional on protocol anymore.

like image 51
Dx_ Avatar answered May 16 '23 09:05

Dx_