Common.Swift:
- import Foundation
- // in objective-c, but in swift, #define can't be used any more
- // use let keyword to define a macro, look up original document:
- /*
- Simple Macros
- Where you typically used the #define directive to define a primitive constant in C and Objective-C, in Swift you use a global constant instead. For example, the constant definition #define FADE_ANIMATION_DURATION 0.35 can be better expressed in Swift with let FADE_ANIMATION_DURATION = 0.35. Because simple constant-like macros map directly to Swift global variables, the compiler automatically imports simple macros defined in C and Objective-C source files.
- */
- // in objective-c
- // #define kCommonAPI @"http://xxxxxxx"
- // but in swift, no #define, just use let to define
- let kCommonAPI = "http://xxxxxxx"
main.swift:
- import Foundation
- println(kCommonAPI)
result:
- http://xxxxxxx
- Program ended with exit code: 0