if (central.state == .poweredOn) kontrolune girmiyor , bluetooth listesi gelmiyor ne yapabilirim ?
import CoreBluetooth import UIKit
class ViewController: UIViewController { var centralManager: CBCentralManager? var peripherals = Array()
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
centralManager = CBCentralManager(delegate: self, queue: DispatchQueue.main)
}
}
extension ViewController: CBCentralManagerDelegate { func centralManagerDidUpdateState(_ central: CBCentralManager) {
print(central.state)
if (central.state == .poweredOn){
self.centralManager?.scanForPeripherals(withServices: nil, options: nil)
}
else {
print("nil")
}
}
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
peripherals.append(peripheral)
print(peripheral)
}
}