[英]Type 'ViewController' does not conform to protocol 'MCSessionDelegate'
i want to write a simple code to test "MultipeerConnectivity" so i use Type 'ViewController' to inherit "MCSessionDelegate" and "MCBrowserViewControllerDelegate" 我想编写一个简单的代码来测试“ MultipeerConnectivity”,所以我使用“ ViewController”类型继承“ MCSessionDelegate”和“ MCBrowserViewControllerDelegate”
but swift always say error like Type 'ViewController' does not conform to protocol 'MCSessionDelegate' 但是迅速总是说类似“ ViewController”类型的错误不符合协议“ MCSessionDelegate”
i see oc code it is easy to realize it,why i change to swift ,it become wrong? 我看到oc代码很容易实现,为什么我改成swift,却变成了错误?
The does not conform to protocol
error appears when you don't implement the required methods of this protocol. 如果您未实现此协议的必需方法,则会出现does not conform to protocol
错误。
In that case, to conform to the MCSessionDelegate
you need to implement session:didReceiveData:fromPeer:
, session:didStartReceivingResourceWithName:fromPeer:withProgress:
, session:didFinishReceivingResourceWithName:fromPeer:atURL:withError:
, session:didReceiveStream:withName:fromPeer:
and session:peer:didChangeState:
在那种情况下,为了符合MCSessionDelegate
您需要实现session:didReceiveData:fromPeer:
, session:didStartReceivingResourceWithName:fromPeer:withProgress:
, session:didFinishReceivingResourceWithName:fromPeer:atURL:withError:
, session:didReceiveStream:withName:fromPeer:
和session:peer:didChangeState:
Take a look at the documentation here , it lists all the required methods for the delegate. 在这里查看文档,其中列出了委托所需的所有方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.