I want to get all the classes in my project userLocation variable. How can I identify as a global? Is that reasonable? Do I have to define each class separately? Also I would like to access the application in the background too.
Thanks
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.
Never use global variables in general (in any programming langage), that’s bad architecture/design in general.
You should use the Singleton Pattern (see Apple Doc) for such stuff of gathering common information or features global to the application. Use it parcimoniously (using it everywhere without justification is also bad design)
In the case of the userLocation, you can anyway get the latest user location retrieved by the GPS using
CLLocationManager‘slocationproperty anyway, so there is no need for a global variable or a singleton for this case.