What is a static property in Objective C.
9.8 Static Variables
Before I explain the static variables to you, you should first have a look at the following program example:
When you run the program, it prints the "value of i: 1" three times. However, one must assume here that the programmer had other intentions, since he is incrementing the value of the variable i at the end of the function. The fact that this does not work has to do with the memory management of the stack. More on this topic can be found in Section 9.20.1, »Excursus: Stack«.
You can now write the keyword static in front of the variable in this program. So change this function:
This means that the values 1, 2 and 3 are actually output for the variable i. You owe this to the keyword static. This is because static variables do not lose their value when their frame of reference is terminated (i.e. when the function is terminated), but instead retain their value. That this succeeds is due to the fact that static variables are not stored in the stack segment of the CPU, but in the data segment. But be careful: Static variables must be initialized when they are declared!
How did you like the Openbook? We always look forward to your feedback. Please send us your feedback as an e-mail to [email protected]
- Should I buy a RE Classic 350?
- Why do you call certain animals pets
- Why are scientists interested in cellular automata?
- Where's the first Taco Bell
- Why do people mispronounce the word at all
- Jews rule Hollywood
- Which company brought the first digital camera to market?
- When will our financial system crash?
- The voting will ruin the voting process
- How do I choose a good pen
- Why is 10 2 5
- How many states are there in India 13
- Why didn't Osama bin Laden kill himself?
- Save jesus
- What is the meaning of h 2pi
- What are scalability and elasticity in AWS
- What is my hair type
- Is the umpteenth a real word
- What is your favorite sailboat
- How to say Kinnow in English
- What is the best treatment for ketoacidosis
- How do we achieve encapsulation in Java
- Who is the best friend
- Air conditioning can be harmful
- Baldness can be cured
- What is the essence of culture
- Light is the fastest on earth
- Can someone buy a Porsche car
- What is entry into force
- You can repair a broken mini fridge
- Architects still use character tables
- How do disabled people have children
- Who would win Darkseid or Chara
- How do I say hello in Spanish