B.Chok
B.Chok

Reputation: 23

Conform to CBCentralManagerDelegate Protocol

I am trying to implement a BLEHandler.

This is my code:

import CoreBluetooth

class BLEHandler : NSObject, CBCentralManagerDelegate {

    override init() {
        super.init()

    }

    func cenrealManagerDidUpdateState(central: CBCentralManager!)
    {
        switch (central.state)
        {
        case . unsupported:
            print("BLE is unsupported")
        case.unauthorized:
            print("BLE is unauthorised")
        case.unknown:
            print("BLE is unknown")
        case.resetting:
            print("BLE is resetting")
        case.poweredOff:
            print("BLE is powered off")
        case.poweredOn:
            print("BLE is powered on")
        default:
            print("BLE default")
        }
    }
}

I get an error: "Type 'BLEHandler' does not conform to protocol 'CBCentralManagerDelegate'"

I have the 'centralManagerDidUpdateState' method so I don't know what I've missed etc.

Upvotes: 0

Views: 445

Answers (1)

Adolfo
Adolfo

Reputation: 1862

Method name is misspelled. Not cenrealManagerDidUpdateState, it should be centralManagerDidUpdateState

Try with...

func centralManagerDidUpdateState(_ central: CBCentralManager)
{

}

Upvotes: 3

Related Questions