IOS macro definition # define

Source: Internet
Author: User

The most basic macro definition usage

# Define aaa bbb

The content of bbb is replaced by aaa.


Macro scope

Macros are used in the current file,

If you want to act on other classes (for example, calling Class a's defined macro in Class B), you need to introduce Class a's header file (a. h) in Class B ).


If you need to act on the entire project, you can define a class such as Config. h, define the required macro in this class, and then in the XXX_Prefix.pch file of the Project # import "Config. h"

In Config. h

# Define aaa bbb


In the XXX_Prefix.pch File

# Ifdef _ OBJC __

# Import

# Import

# Import "Config. h"

# Endif


To modify the XXX_Prefix.pch file of the project to YYY_Prefix.pch, you can modify it as follows:

Project -- targets -- build settings -- Prefix Header option in AppleLLVM 5.0 Language.

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.