problem description
I have two ViewController, one ViewA to search and display the Bluetooth list, and one ViewB to control the operation of Bluetooth devices. Now I inherit CBCentralManagerDelegate
, CBPeripheralDelegate
on ViewA and search for the desired device in didDiscover
, and then successfully connect the device in didConnect
.
at this point I need to enter ViewB and operate Bluetooth device or monitor Bluetooth data in ViewB, but I can"t get peripheral
which is connected successfully in ViewA. So is there any way that a device that I can successfully connect to in ViewA can be used directly in ViewB?
what methods have you tried
I found on the Internet that someone said to use singleton mode, create a singleton of BLEManager
, and then use this singleton directly in ViewA and ViewB, but for example, didDiscover
is an asynchronous method. How can I tell this singleton in ViewA that discover
starts now?