0

I'm in the final stretch of building my first iOS app and I wanted to know the best practices for passing around the user or not. Do I pass the user to every controller or is there a store-like infrastructure I can set up to store all runtime data in, or do I fetch from local storage every time I need the user?

Also when I close my simulator, the user is logged out of my backend. Does that mean that I should store the user password in local storage to sign them back if they have logged in before or is that bad practice?

If these questions have been answered else where please send me a link to a discussion along these lines.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
NojDavid
  • 89
  • 1
  • 10
  • 1
    This is very broad. A lot of this is decisions you need to make. You can pass the user along to every controller, you can use a singleton for your user, you can fetch it from whatever storage you're using, you can make a centralized store that you pull from. Each have pros/cons that you will need to weigh for your app. As far as storing the password, this should be saved in the system Keychain. DO NOT save the password anywhere other than Keychain https://stackoverflow.com/questions/6972092/ios-how-to-store-username-password-within-an-app – Sean Kladek Jul 10 '18 at 17:10
  • Thanks for the tip on the keychain thats definitely what i need to store user info. And i think the singleton design pattern is what i needed, thank you for the refresher – NojDavid Jul 10 '18 at 17:19

0 Answers0