@ Import and # Use of import,

Source: Internet
Author: User

@ Import and # Use of import,

In xcode 5, the new modules and auto-linking features are added to make project development easier. Using @ import to add a framework project is more effective than using # import.

Modules and auto-linking are enabled by default. For the old project, you can set Enable Modules and Link Frameworks Automatically to Yes by setting "Language-Modules.

Another advantage of using moudules is that you no longer need to link your framework to your project. For example, in the past, if you want to use the MapKit framework, you need to do so. 1) Use the statement # import <MapKit/MapKit. h> Import framework 2) Go to the build phases setting item of the project and find MapKit. framework. and add it to Link Binary With Libraries. If you use modules, you only need to add the statement "@ import MapKit;" to start using it, and do not need to link to your project. Therefore, using @ import instead of # import in ios 7 or later versions makes development more convenient.

 

Additional:

@ Class is generally used to declare an instance variable of this class in the header file. In the m file, you still need to use # import to import the corresponding class. # Compared with # include, import does not cause cross-compilation. In Objective-C, # import is used as an improved version of the # include command. In addition, # import determines that a file can only be imported once, so that the project developers will not encounter problems in recursive inclusion. "" Indicates a self-created file, which will be first searched in the current directory. If it cannot be found, it will be searched elsewhere, "" And <> are relative to the files created by the user, and the files created by the system.

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.