@property Declaration Properties
The way to specify attributes (attributes) For instance variables allows the compiler to generate leak-free and thread-safe ways to access instance variables.
@property is the corresponding compiler directive
Declares a property that has the same name as a data member to omit read and write functions
@interface application { int versioncode; int userId; userinfo* UserInfo; Applicationinfo*applicationinfo;
}
@property (retain) UserInfo *userinfo; @synthesize UserInfo; @property (retain) applicationinfo* applicationinfo; @synthesize ApplicationInfo; @end
The syntax for declaring a property is:
@property (parameter) type name;
The parameters here are divided into three main categories:
Read-Write properties: (readwrite/readonly)
Setter semantics: (assign/retain/copy)
Atomicity: (Atomicity (nonatomic)
Assign/retain/copy determines how to assign new values to data members
The default value for Atomicity is atomic, and the Read function is atomic.
The parameters that are often used are copy/reain/assign.
The setter in which to determine the property determines how to handle this property. Many of the objects in Objective-c are best used with retain, some special object (for example: string) using Copy.
The Assign keyword represents the setter's direct assignment, rather than copying or preserving it. This mechanism works well for some basic types, such as Nsinteger and cgfloat, or types that you do not directly own, such as delegates.
The ReadOnly keyword means that the setter will not be generated, so it cannot be used in combination with copy/retain/assign.
In the implementation, you only need to
@synthesize MainView;
@synthesize window;
Can replace the cumbersome setter, getter method, so that the compiler can automatically generate read and write functions, define the property, the user, you can click the number (.) To access the attribute.