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()
}
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.