クラスを var bluetoothManager = CBPeripheralManager(delegate: self, queue: nil, options: nil) として初期化したのに、CBPeripheralManagerDelegate メソッドが呼び出さないのはなぜですか?
バンドルに BlueTooth Framework を既に追加しています。
import UIKit
import CoreBluetooth
class AppSettingsViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
var bluetoothManager = CBPeripheralManager(delegate: self, queue: nil, options: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
extension AppSettingsViewController : CBPeripheralManagerDelegate{
func peripheralManagerDidUpdateState(peripheral: CBPeripheralManager!) {
if peripheral.state == CBPeripheralManagerState.PoweredOn{
println("broadcasting")
}else if peripheral.state == CBPeripheralManagerState.PoweredOff{
println("no bluetooth found")
}else if peripheral.state == CBPeripheralManagerState.Unauthorized {
println("This option is not allowed by your application")
}
}
}