Ios#import and # Include and @class usage

Source: Internet
Author: User

#include <>: For references to system files, the compiler looks for the file in the System files directory. #include "xx.h": for a user-defined file reference, the compiler will first go to the user directory to find, and then go to the installation directory, and finally to the system directory lookup. Note: #include: If Class A imports Class B, the header file of Class B imports the header file of Class A, so that a circular reference occurs. So we try not to import the user-defined class file in the. h file. h (But if there is an agent in the. h file, you can To import another. h directly in. h or you can write an. h file separately for the agent) and #import if Class A imports Class B, the header file of Class B is imported into Class A's header file, and a cross-import occurs. #import function and Include is basically the same, but it avoids the problem of duplicate references. So in OC we basically use import.

@class is typically used when you need to define a property of a certain type in the. h header file, to prevent the import of another. h file in the. h file, and to prevent the loop from being imported, but be sure to #import the corresponding. h file in. m after using @class in. h Note: Do not import. m files for another class in. m

Ios#import and # Include and @class usage

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.