I'm working on a project where I have an app that receives data over BLE from a wearable peripheral, but I'm struggling with how to architect the app. Currently I have a singleton BLEManager class that constantly receives data in the background and then uses NSNotificationCenter to send it to the active view controller. This works but has gotten messy and seems non-ideal since I have multiple view controllers that each process the data in the same way and then just display it differently. Additionally, there are some settings related to the data processing that can be changed in app and need to be the same everywhere. It would be nice if the BLEManager sent the data to a central processing class and then the processed data was sent to the active view controller but I'm not sure the best way to set this up.
I could incorporate all the processing into the BLEManager class but then it would get pretty bloated and unintuitive and wouldn't be nice to work with moving forward. If I make a separate processing class thats a property of the BLEManager then I'd have to go through the BLEManager if I wanted to get or change any variables in the processing class from anywhere else which would be annoying. I could make a singleton processing class that receives data from the BLEManager and then sends it to the active VC but I've seen people say to avoid singletons so I'm hesitant to use another one even though this seems like it could be a good solution.
Is there a standard or recommended way to architect an iOS app to process incoming data from Bluetooth and then send it wherever its needed?
Aucun commentaire:
Enregistrer un commentaire