【发布时间】:2014-11-05 18:11:14
【问题描述】:
当我运行我的代码并在我的 MacbookPro 上打开/关闭蓝牙时,状态始终为 4,对应于 PoweredOff 状态。
import Cocoa
import CoreBluetooth
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate, CBCentralManagerDelegate {
var centralManager = CBCentralManager()
func applicationDidFinishLaunching(aNotification: NSNotification) {
centralManager = CBCentralManager(delegate: self, queue: nil)
}
func centralManagerDidUpdateState(central: CBCentralManager!) {
switch central.state {
case .PoweredOn:
println(".PoweredOn")
case .PoweredOff:
println(".PoweredOff")
case .Resetting:
println(".Resetting")
case .Unauthorized:
println(".Unauthorized")
case .Unknown:
println(".Unknown")
case .Unsupported:
println(".Unsupported")
}
}
}
我知道蓝牙实际上已开启,因为我已经能够将它与我的手机配对。
【问题讨论】:
标签: swift osx-mavericks core-bluetooth