How to run code during the iOS development process specifically during debugging

Source: Internet
Author: User

During the development process, we often use NSLog to track debugging, but the products that are released may not want these debug code to be run. Here's a little tip to share.

You can use the following methods when writing code:

#ifdef debug<

Debug Mode code ...

#else <

Release Mode code ...

#endif

The debug is already defined in the Xcode default project, and you can add other constant definitions based on your actual situation.

In Xcode, select the root node at the top left of the navigation area and select Project/build Settings and enter debug in the search box to see the definition as shown in the following illustration:

If you want to test how the code works in different modes, you can choose Product/scheme/edit Scheme to modify the build configuration, as shown in the following illustration:

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

Tip: Release mode is not running on the real machine, you can choose the emulator to run the viewing effect.

You can use this technique when developing IAP applications so that you don't have to change your verification address every time, the sample code is as follows:

Define part of code:

#define ITMS_PROD_VERIFY_RECEIPT_URL @ "Https://buy.itunes.apple.com/verifyReceipt"

#define ITMS_SANDBOX_VERIFY_RECEIPT_URL @ "Https://sandbox.itunes.apple.com/verifyReceipt";

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.