Thanks for your answer and sorry if this was a novice question, but I am pretty new to app development.
After searching for "iOS Singleton", I found this thread on SO which describes my problem pretty well: https://stackoverflow.com/questions/42088851/creating-a-singleton-for-bluetooth-in-swift-3
I set the delegate via a function in my Singleton class, which I call in AppDelegate.swift after launching the app.
func startBluetooth() {
manager = CBCentralManager(delegate: self, queue: nil)
}
Now I want to scan for peripherals and list them in a table view to connect to one of them selected by the user. I already have the standard function to show the discovered peripherals.
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
print("\(String(describing: peripheral.name)): \(peripheral)")
}
How can I get access to all the discovered peripherals in a VC?