IOS basics-Four Range types of instance variables and four types of ios instance variables
1. to force an object to hide its data, the compiler limits the scope of instance variables to restrict its visibility in the program.
However, to provide flexibility, Apple also allows developers to display the Set range (select one from four ).
2. Four compilation commands are as follows:
@ Private
Instance variables can only be accessed by declared classes.
@ Protected
The instance variable can be declared as its class and subclass. All instance variables that do not display a specified range are @ protected.
@ Public
Instance variables can be accessed anywhere.
@ Packge
When modern is used for running, a @ package instance variable is actually @ public in the executable file image implementing this class, but it is @ private outside.
The @ package in OC is similar to the variables in C language and the private_extern of the function. Any image other than the implementation class image that wants to use this instance variable will cause link error.
This type is most commonly used for instance variables of the framework class. @ private is too restrictive and @ protected or @ public is too open.