Type ‘Class’ does not conform to protocol ‘MCSessionDelegate’

I’m working on migrating my code from Swift 2.X to 3.X and have already resolved majority of my runtime error except one that keeps on bugging out. I have all the required functions and have cleaned and deleted the derived data but it still saying that my class does not conform to ‘MCSessionDelegate’.

 

import MultipeerConnectivity
import Foundation

class Cashier: Advertiser
{
    var waiterBecomesConnectedHandler: ((MCPeerID) -> Void)?
    var waiterBecomesDisconnectedHandler: ((MCPeerID) -> Void)?
}

extension Cashier: MCSessionDelegate {
    // Remote peer changed state.
    @available(iOS 7.0, *)
    public func session(_ session: MCSession, peer peerID: MCPeerID, didChange state: MCSessionState){
     switch state {
            case .notConnected: // not in the session
                waiterBecomesDisconnectedHandler?(peerID)
                connectedPeerSessions.removeValue(forKey: peerID)
                break
            
            case .connected: //
                waiterBecomesConnectedHandler?(peerID)
                break
            
            case .connecting: // connecting to this peer
                break
        }

    }
   
   
    // Received data from remote peer.
    @available(iOS 7.0, *)
    public func session(_ session: MCSession, didReceive data: Data, fromPeer peerID: MCPeerID){
       
    }
   
   
    // Received a byte stream from remote peer.
    @available(iOS 7.0, *)
    public func session(_ session: MCSession, didReceive stream: InputStream, withName streamName: String, fromPeer peerID: MCPeerID){
       
    }
   
   
    // Start receiving a resource from remote peer.
    @available(iOS 7.0, *)
    public func session(_ session: MCSession, didStartReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, with progress: Progress){
       
    }
   
   
    // Finished receiving a resource from remote peer and saved the content
    // in a temporary location - the app is responsible for moving the file
    // to a permanent location within its sandbox.
    @available(iOS 7.0, *)
    public func session(_ session: MCSession, didFinishReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, at localURL: URL, withError error: Error?){
       
    }
   
}

I used the automatic stub that XCode is suggesting but it generates this stub:

    @available(iOS 7.0, *)

    public func session(_ session: MCSession, didStartReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, with progress: Progress){

} 

Which I already have in my class. Any help would be great!

Powered by WPeMatico

About

You may also like...

Comments are closed.