私はiOS10に移行していますが、iOS9でも実行するにはコードが必要です。私はCoreBluetoothとCBCentralManagerDelegateを使用しています。私はiOS10のために働くために私のコードを得ることができますが、私はiOS9のために働くためにフォールバックが必要です。CBCentralManager iOS10とiOS9
func centralManagerDidUpdateState(_ central: CBCentralManager) {
if #available(iOS 10.0, *) {
switch central.state{
case CBManagerState.unauthorized:
print("This app is not authorised to use Bluetooth low energy")
case CBManagerState.poweredOff:
print("Bluetooth is currently powered off.")
case CBManagerState.poweredOn:
print("Bluetooth is currently powered on and available to use.")
default:break
}
} else {
// Fallback on earlier versions
switch central.state{
case CBCentralManagerState.unauthorized:
print("This app is not authorised to use Bluetooth low energy")
case CBCentralManagerState.poweredOff:
print("Bluetooth is currently powered off.")
case CBCentralManagerState.poweredOn:
print("Bluetooth is currently powered on and available to use.")
default:break
}
}
}
私はエラーを取得する:
case CBCentralManagerState.unauthorized:
だけでなく.poweredOffと.poweredOn用:行で
Enum case 'unauthorized' is not a member of type 'CBManagerState'
。
どちらの場合でもどのように動作させることができますか?
このリンク をチェックhttps://forums.developer.apple.com/thread/51222 – Sujit
私はこれを試してみましたが、私はできませんでしたどちらかの解決策を得るには – cjbatin