Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift - BTLE - How to Add CBCentralManagerDelegate Protocal

I want to make an ios app that use bluetooth to communicate. I am using swift.

So first I add the CoreBluetooth.framework, then I add a bridge.h and add file to the system bridge, import "CoreBluetooth/CoreBluetooth.h".

Then I create a new class,

import UIKit

class BTCentral: NSObject, CBCentralManagerDelegate   {

}

I am planning to create a bluetooth CBCentralManager in that class. However, the above code gives me an error.

Type 'BTCentral' does not conform to protocol 'CBCentralManagerDelegate' 

Here is a specific ScreenShot: click here

Any help will be appreciated! Thank you guys so much for your time.

like image 624
nuynait Avatar asked Jun 16 '14 14:06

nuynait


1 Answers

You have to implement all the methods required by the protocol. In this case, CBCentralManagerDelegate only requires that one method be implemented, centralManagerDidUpdateState().

Add this method to your class and the error will go away.

func centralManagerDidUpdateState(central: CBCentralManager!) {

}
like image 88
Mick MacCallum Avatar answered Dec 10 '22 07:12

Mick MacCallum