I'm working on an app that will need a user to be logged in. I've been thinking about the ways to design the User class and it seems to me like a singleton with a private init
would be the ideal solution, since it would be accessible code wide and could work together with NSUserDefaults for storing when the app goes into background. However I've read a bunch about singletons and some people seem to seem think they should almost never be used.
Does my use case scenario call for the use of a singleton? Should it be avoided? If so, what are the common design patterns used when writing a single-user app?
Aucun commentaire:
Enregistrer un commentaire