When defining classes in Objective-c, you can also use public and private variables similar to C ++ to modify member variables, as shown below:
[Cpp]
@ Intterface Test: NSObject {
@ Public
Int I;
Int j;
@ Protected
Float m;
Float n;
@ Private
Double x;
Double y;
}
@ Intterface Test: NSObject {
@ Public
Int I;
Int j;
@ Protected
Float m;
Float n;
@ Private
Double x;
Double y;
} Www.2cto.com
@ Protected: The instance variables modified with this command can be directly accessed by this class and any subclass. This is the default situation.
@ Private: The instance variables modified with this command can be directly accessed by the methods defined in this class, but cannot be accessed directly by the methods defined in the quilt class.
@ Public: The instance variables modified with this command can be directly accessed by methods in this class, or by methods defined by other classes.
Note: in actual use, we cannot directly access the attribute of @ private permission, but the test program can be correctly executed, but Xcode will give a warning.
Author: