简体   繁体   中英

Type 'AppDelegate' does not conform to protocol 'WCSessionDelegate' calls infinity times

I wan't to pair iphone application with AppleWatch , when i'm implement to AppDelegate a WCSession delegate , they always show to me error "Type 'AppDelegate' does not conform to protocol 'WCSessionDelegate'" But i'm added the function of this protocol Here i'm implement code of protocol

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

enter image description here

Below the AppDelegate class add this extension that confirm to the delegate protocol and use it subs

extension AppDelegate: WCSessionDelegate { 
//use WCSessionDelegate functions
} 

Add below methods for WCSessionDelegate

func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) {

}

func sessionDidBecomeInactive(_ session: WCSession) {

}

func sessionDidDeactivate(_ session: WCSession) {

}

This are required methods for WCSessionDelegate

And just clean and rebuild your project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM