----Common macro definitions and explanations for iOS development

Source: Internet
Author: User

__file__

directory where the current file is located

__date__

"Alternate text" is a string literal with a compile date formatted as "MM DD yyyy" (For example: "Mar 19 2006"). If the date is less than 10th, a space character is placed in front of the day. NSLog (@ "_date_=%s", __date__);

__function__ Current function name __line__ the number of lines in the source file for the current statement __time__
This string literal contains the compile time in the format "HH:MM:SS" (Example: "08:00:59"). __stdc__
An integer constant of 1, which indicates that this compiler follows the ISOC standard. __stdc_version__ How to implement composite C89 full 1, the value of this macro is 19940SL, if the implementation conforms to C99, then the value of this macro is 199901L; otherwise the value is undefined __stdc_eobted__ (C 99) Implementation for the host when implemented as 1, implemented as a standalone implementation of 0
__stdc_iec_559__ (C99) floating point number to achieve composite IBC 60559 standard when defined as 1, no value is undefined
__STDC_IEC_559_COMPLEX__ (C99) complex operation to achieve composite IBC 60559 standard when defined as 1, no value is undefined
__STDC_ISO_10646__ (C99) is defined as a long integer constant, YYYYMML represents the wchar_t value of the composite ISO 10646 standard and its specified revision supplement, otherwise the value is undefined

1. When release, block log

C code
    1. #if defined (Debug) && debug = = 1
    2. #else
    3. #define NSLOG (...) {};
    4. #endif

2. Block is executed in the main thread or in the background

C code
    1. #define BACK (block) Dispatch_async (dispatch_get_global_queue (dispatch_queue_priority_default, 0), block)
    2. #define MAIN (Block) Dispatch_async (Dispatch_get_main_queue (), block)

3. Equipment related

C code
    1. #define Isretina ([UIScreen instancesrespondtoselector: @selector (currentmode)]? Cgsizeequaltosize (Cgsizemake (640, 960), [[UIScreen Mainscreen] currentmode].size): NO)
    2. #define IPHONE5 ([UIScreen instancesrespondtoselector: @selector (currentmode)]? Cgsizeequaltosize (Cgsizemake (640, 1136), [[UIScreen Mainscreen] currentmode].size): NO)
    3. #define ISPAD (ui_user_interface_idiom () = = Uiuserinterfaceidiompad)
    4. #define Currentsystemversion ([[Uidevice Currentdevice] systemversion])
    5. #define CURRENTLANGUAGE ([[Nslocale preferredlanguages] objectatindex:0])

4. Distinguish between simulator and real machine

C code
    1. #if Target_os_iphone
    2. IPhone Device
    3. #endif
    4. #if Target_iphone_simulator
    5. IPhone Simulator
    6. #endif

5, depending on whether to use ARC to do different operation

C code
    1. #if __has_feature (OBJC_ARC)
    2. Compiling with ARC
    3. #else
    4. Compiling without ARC
    5. #endif

----Common macro definitions and explanations for iOS development

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.