Deep Arora
Deep Arora

Reputation: 2040

Why Class doesn't confirm to protocol 'WCSessionDelegate' error showing even when all required methods are implemented

Here't the part of the code that I have used:

class RealTimeVC : UIViewController, WCSessionDelegate{
   var session : WCSession!
   override func viewWillAppear(animated: Bool)
    {
        if (WCSession.isSupported())
        {
            session = WCSession.defaultSession()
            session.delegate = self
            session.activateSession()

        }
    }

    //WCSessionProtocol

    func session(session: WCSession,
                 activationDidCompleteWith activationState: WCSessionActivationState,
                 error: NSError?){
        print("Print Something")
    }

    func sessionDidBecomeInactive(session: WCSession){
         print("Print Something")
    }

    func sessionDidDeactivate( session: WCSession){
         print("Print Something")
    }

}

If the class doesn't implement WCSessionDelegate protocol, then there is no compiler error.I am using Xcode 8 Beta, Swift 3 and deployment target is iOS10 and WatchOS 3.

Upvotes: 1

Views: 507

Answers (1)

ccjensen
ccjensen

Reputation: 4656

It looks like the "activation did complete" delegate callback that you've implemented doesn't quite match the one required by the protocol. Once you fix that you should find the compiler will accept your protocol conformance!

Upvotes: 1

Related Questions