Global constants
Global constants defined in the C and Objective-c language source files are automatically introduced by Swift compilation and are global constants of Swift.
preprocessing directives
The Swift compiler does not contain pre-processors. Instead, it takes advantage of compile-time properties, build configurations, and language features to accomplish the same functionality. Therefore, Swift does not introduce pre-processing instructions.
Simple macro
In C and objective-c, you typically use the # define directive to define a simple constant, and in swift you can use global constants instead. For example: Define a constant of # define Fade_animation_duration 0.35, which is better if you use let Fade_animation_duration = 0.35来 in Swift. Because simple macros that define constants are directly mapped to Swift Global, the Swift compiler automatically introduces simple macros defined in C or objective-c source files.
Complex macros
The complex macros used in C and objective-c do not correspond to anything in Swift. Complex macros are macros that are not used to define constants, and function-type macros that contain parentheses. You use complex macros in C and objective-c to avoid the limitations of type checking or to avoid retyping a large number of boilerplate code. However, macros can also cause debug and refactoring to be more difficult. In Swift you can use functions and generics to achieve the same effect, without any compromise of grievance. Therefore, complex macros defined in the C and Objective-c source files are not available in Swift.
Examples of Use:
globalconst. swift// liqunswiftdemo//// Created by HF on 15/11/3.// copyright©2015 year HF-ZHJH. All rights reserved.//import foundationimport Uikitlet webapibaseurl = "http://baidu.com" //simple macro as global constant let color_th Eme_green:uicolor = GetColor (1)//complex macros with functions This example is too weak to be supplemented later there is a generic knowledge of the Func-GetColor (Mycolor:int), uicolor{ Return Uicolor (colorliteralred:0.08, green:0.64, blue:0.0, alpha:1)}/////////////////////can be called directly in place of use
IOS Swift constants && Macro definitions