Use Xcode-debug and release modes, and xcode-debugrelease

Source: Internet
Author: User

Use Xcode-debug and release modes, and xcode-debugrelease

In the development process, we often need to use NSLog to output some information, or even some development processes, which must be viewed in the console, experienced programmers can use the console to output the entire data interaction process. However, a published program contains too many NSLog outputs, which must have an impact on App performance. At this time, we can use a macro definition for processing and use the DEBUG mode during development, use the RELEASE mode during RELEASE. In this way, the published App will not output a large number of nslogs in the program.

The simple code is as follows,

?
1234 #if defined(DEBUG)||defined(_DEBUG)    NSLog(@"Test code");    NSLog(@"Test Coding");#endif

The # if # endif macro above defines that if DEBUG is defined, NSLog output is used; otherwise, this code is ignored directly. Some people may wonder where the DEBUG and _ DEBUG come from. You don't have to worry about this. This is from the default setting of Xcode. We can cancel the DEBUG mode and enable the RELEASE mode, as shown below,

Choose Product> Scheme> Edit Scheme,

You can select Debug and Release modes,

If Release is selected here, no Debug is defined by default, the output NSLog between # if... # endif in the above Code will not be executed. In this way, resources of some hardware devices are saved when the program is released.

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.