NSNotificationCenter for Modal Loading screen
I know that generally speaking, it's not considered awesome practice to use NSNotificationCenter when you could just hook something up directly in code and have the explicit dependency. However, I'm in a situation where I have this loading screen view that needs to be presented modally whenever some part of the app needs to load something (sometimes overlapping asynchronous processes). These situations are scattered throughout the code. Would broadcasting be an acceptable use case of NSNotificationCenter? In other words, various services would broadcast a loading_start/loading_finish and the view would present and dismiss itself as necessary.
As it stands, I have it hooked up explicitly in various places and I'm getting the very occasional crash report:
Fatal Exception: NSInvalidArgumentException
Application tried to present modally an active controller
Since I'm searching for this issue, I'm thinking overhauling it to use NSNotificationCenter would simply things and allow the loading view controller to figure everything out rather than litter my code with dependancies. I'm still somewhat new to application architecture, so any advice is welcome.
Posted Jul 13, 2016, 3:13 PM UTC