简体   繁体   English

类型“ ViewController”不符合协议“ MCSessionDelegate”

[英]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.

相关问题 类型“ ViewController”不符合协议 - Type 'ViewController' does not conform to protocol 类型'ViewController'不符合协议'UICollectionViewDataSource' - Type 'ViewController' does not conform to protocol 'UICollectionViewDataSource' 类型“ ViewController”不符合协议“ UISearchResultsUpdating” - Type 'ViewController' does not conform to protocol 'UISearchResultsUpdating' Swift:类型'ViewController'不符合协议'UIPageViewControllerDataSource' - Swift: Type 'ViewController' does not conform to protocol 'UIPageViewControllerDataSource' 类型“ viewController”不符合协议“ PathMenuDelegate” - type “viewController” does not conform protocol “PathMenuDelegate” 类型的viewcontroller不符合协议uitableviewdatasource - type viewcontroller does not conform to protocol uitableviewdatasource 类型“ ViewController”不符合协议“ FBSDKLoginButtonDelegate” - The type 'ViewController' does not conform to protocol 'FBSDKLoginButtonDelegate' ViewController类型不符合协议SKPaymentTransactiionObserver - type ViewController does not conform to protocol SKPaymentTransactiionObserver 类型“ ViewController”不符合协议“ UITableViewDataSource” - Type “ViewController” does not conform to protocol 'UITableViewDataSource" 类型“ViewController”不符合协议“UITableViewDataSource” - Type 'ViewController' does not conform to protocol 'UITableViewDataSource'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM