Objective-c: Comparison of three ways to import files

Source: Internet
Author: User
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 variable and method is how to define, will tell you, now you can directly use it, save the program compile time, 2, adopt import way, can avoid duplicate import the same class, It imports not only the contents of this class, but also before using it, the compiler must first go through all the contents of the class, that is, to do the pre-compilation process, so that the time spent compiling the program. 3, the use of include method, can not avoid the problem of repeated import, but it is used in the code writing in 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 it's best to use this approach if you're writing programs that cross-platform . 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.

Objective-c: Comparison of three ways to import files

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.