How iOS operates Bluetooth between different View

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?

Jun.23,2022

in the simplest way, you can send messages.

[[NSNotificationCenter defaultCenter] postNotificationWithName:@"your name" object:nil];
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c0c703-32ae2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c0c703-32ae2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?