one or three ways to import files are compared:
@class, import, include in the preceding paragraph of the class:
1, the use of @class class name, it will tell the compiler has such a class, currently do not need to know its internal instance variables and methods are defined, will sue you, now you can directly use it, save the program compile time; 2, the use of Import mode, can avoid repeated import of the same class, it imports not only the contents of this category, and before using it, the compiler must first of all the contents of the class to go through, is to do pre-compilation processing, so that the time spent compiling the program. 3, using the Include method, can not avoid the problem of duplicate import, but it is used in the code writing of C + +, because #ifndef, #define, #endif这个是C/c++ language macro definition, macro definition to avoid multiple compilation of files. So it's all valid on all compilers that support C + + languages, and if you write programs that cross-platform, it's best to use this approach. Description: When you write the OC code, if you declare a file in a class. h, when another class is required, the use of the preceding clause to declare the @class class name is the best choice because it omits the time for code compilation and improves efficiency, but in implementing the file. m file, you must use import Because the instance variables and methods of the class are used in the implementation file, the compiler must first pre-compile the contents of the class in advance. Ii. The difference between atomic and nonatomic:
Atomic: When setting the @property property of a member variable, the default is atomic, which provides multithreading security. Because of multithreading, all objects in the operation of the member variables are synchronous, so, in order to prevent an object in the operation of data is not finished by another object snatched by the tampering,atomic for this provides a multi-threaded security mechanism, the use of synchronous locking method to control the process of ownership. namely:{Lock}//The first object gets operation data, locks its own process, and others cannot rob until I have released the lock.
if (Property! = newvalue) {
[Property release];
Property = [newvalue retain];
}
{unlock}//After the object has finished manipulating the data, the synchronization lock is released, and someone else can get the data to do their own work. Description: The lock must be unique. nonatomic: When setting the @property property of a member variable, set Nonatomic to prohibit multithreading. This directly eliminates the possibility of tampering by the other side of the data operation. This setting is generally used if it is not multi-threaded.
Objective-c: Three ways to import files and the difference between atomic and nonatomic