-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
Upgrading the app to the scene-based life cycle (#434) once again showed how useful an object registry would be.
With the scene-based life cycle, the owner of the application main window is now the SceneDelegate, no longer the ApplicationDelegate. However, many places used this snippet
[[ApplicationDelegate sharedDelegate].window.rootViewController
to gain access to the window object. All of these places now need to updated to reflect the new window object ownership.
Having an object registry would have prevented the coupling to ApplicationDelegate as the window object owner. Instead, those who need access to the window object could have retrieved the object from the registry.
The goal of this issue therefore is to introduce an object registry. Some thoughts:
- Registrations must be made with an instantiated Registry object, i.e. don't perform static storage registrations.
- For the initial implementation it's probably ok to make the Registry a Singleton. If it becomes necessary later the Registry can be modified to allow multiple instances.
- Consider propagating the Registry object reference via initializer, instead of letting everyone getting the shared Registry by themselves via a Singleton method (e.g.
[Registry sharedRegistry]). - How flexible should the registry be? Should it have a dedicated getter/setter for each known object, or should it be made super-flexible and use a string key to get/set objects?
- Consider registering by protocol only, instead of registering by concrete class. For instance, consider registering a
WindowProviderinstead ofSceneDelegate(or the window object itself).
Reactions are currently unavailable