Przeprowadzam migrację do iOS10, ale potrzebuję również kodu do uruchomienia na iOS9. Używam CoreBluetooth i CBCentralManagerDelegate. Mogę sprawić, by mój kod działał na iOS10, ale potrzebuję również funkcji awaryjnej do pracy z iOS9.CBCentralManager iOS10 i 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
}
}
}
pojawia się błąd:
Enum case 'unauthorized' is not a member of type 'CBManagerState'
Na linii:
case CBCentralManagerState.unauthorized:
jak również dla .poweredOff i .poweredOn.
Jakieś pomysły, w jaki sposób mogę je uruchomić w obu przypadkach?
Sprawdź ten link https://forums.developer.apple.com/thread/51222 – Sujit
próbowałem tego, ale nie mogłem otrzymasz swoje rozwiązanie do pracy albo – cjbatin