When you define a class in Objective-c, you can also use a public, private, similar to C + + to decorate member variables, as follows:
[CPP]View Plaincopy
- @intterface test:nsobject{
-
- @public
- int i;
- INT J;  
-
- @PROTECTED  
- FLOAT M;  
- FLOAT N;  
-
- @PRIVATE  
- DOUBLE X;  
- DOUBLE Y;  
-
- }  
@protected: An instance variable decorated with this directive can be accessed directly by the method determined by that class and any subclass, which is the default.
@private: Instance variables decorated with this directive can be defined directly in the methods of the class, but cannot be accessed directly by the methods defined in the class.
@public: Instance variables decorated with this directive can be accessed directly by methods in the class, or by methods defined by other classes.
Note that in actual use, we cannot directly access the properties of the @private permission, but the test program can be executed correctly, but Xcode will give a warning.
Objective-c access Control