I’m developing an app the accesses a web server by REST. I want to keep the session ID for any View Controller or Class can access it. What is the correct (or the best) way to do it? Singletons, global variables or neither?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If the session only has 1 field and you want to save it in case the app is closed, NSUserDefaults is the simplest way.
If you don’t want to save the session or if it’s complex, you should use singleton.