[IOS development-69] the output function is customized in the pch file. This method is generally adopted by company projects to facilitate development, testing, and release,

Source: Internet
Author: User

[IOS development-69] the output function is customized in the pch file. This method is generally adopted by company projects to facilitate development, testing, and release,

In the latest Xcode, no pch file exists by default, and you need to manually create the file.


In fact, a pch file is similar to a macro. Its content can be accessed and shared by other files.


Therefore:

-- You can define macro variables here

-- Of course, the actual usage is mostly used for testing. For example, the following statement indicates that we can use WPLog instead of NSLog to print the output test in the development and test phase. In the release phase, the WPLog will automatically expire. Generally, NSLog is rarely directly used in company projects. Replace is basically defined in the pch file.

# Ifdef DEBUG # define WPLog (...) NSLog (_ VA_ARGS _) # else # define WPLog (...) # endif

-- In the previous study, we found that an error was reported when using CGRect, which is actually a bad header file. In earlier versions of Xcode, the following code is used:

# Ifdef _ OBJC _ # import <UIKit/UIKit. h> # import <Foundation/Foundation. h> # endif

The latest Xcode version seems to be:

# Ifdef _ OBJC _ # import <Foundation/Foundation. h> # endif

Therefore, you can either add UIkit. h to each required header file or add it in the pch file.

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.