I don’t understand why variables are declared as static in Objective-c class methods?
What is the scope of the static variables?
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.
staticvariables don’t get destroyed when their stack frame is popped off the stack (normal variables do, otherwise you’d get epic memory leaks). See them as global variables you can only access locally. They’ll stay alive till the entire program terminates.Example: