[英]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我不想将 iphone 应用程序与 AppleWatch 配对,当我实现 AppDelegate WCSession 委托时,它们总是向我显示错误“类型‘AppDelegate’不符合协议‘WCSessionDelegate’”但我添加了这个协议我在这里实现了协议的代码
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在AppDelegate类下面添加这个扩展,确认委托协议并使用它 subs
extension AppDelegate: WCSessionDelegate {
//use WCSessionDelegate functions
}
Add below methods for WCSessionDelegate
为
WCSessionDelegate
添加以下方法
func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) {
}
func sessionDidBecomeInactive(_ session: WCSession) {
}
func sessionDidDeactivate(_ session: WCSession) {
}
This are required methods for WCSessionDelegate
这是
WCSessionDelegate
所需的方法
And just clean and rebuild your project.只需清理并重建您的项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.