簡體   English   中英

類型“ ViewController”不符合協議“ MCSessionDelegate”

[英]Type 'ViewController' does not conform to protocol 'MCSessionDelegate'

我想編寫一個簡單的代碼來測試“ MultipeerConnectivity”,所以我使用“ ViewController”類型繼承“ MCSessionDelegate”和“ MCBrowserViewControllerDelegate”

但是迅速總是說類似“ ViewController”類型的錯誤不符合協議“ MCSessionDelegate”

我看到oc代碼很容易實現,為什么我改成swift,卻變成了錯誤?

如果您未實現此協議的必需方法,則會出現does not conform to protocol錯誤。

在那種情況下,為了符合MCSessionDelegate您需要實現session:didReceiveData:fromPeer:session:didStartReceivingResourceWithName:fromPeer:withProgress:session:didFinishReceivingResourceWithName:fromPeer:atURL:withError:session:didReceiveStream:withName:fromPeer:session:peer:didChangeState:

這里查看文檔,其中列出了委托所需的所有方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM