BLE Peripheral disconnects when navigating to different ViewController

Create a Singleton class and add bleManager and peripheral properties there:

class Shared { 
    private init(){ } 
    static let instance = Shared()
    var bleManager: BLEManager!
    var peripheral: CBPeripheral! 
}

And you can access the same instance through different controllers:

Shared.instance.bleManager = BLEManager() 

Leave a Comment