swift 学习这十八:宏()
来源:互联网 发布:as3.0调用js页面方法 编辑:程序博客网 时间:2024/06/05 03:09
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
0 0
- swift 学习这十八:宏()
- swift 学习这十八:宏()
- 析构—Swift学习笔记(十八)
- swift学习-错误处理(十八)
- swift学习之路(十八)泛型
- Swift学习笔记(十八)泛型
- Swift基础(十八)UISegmentedControl
- Swift学习笔记(十八)——字符串String.Index和Range详解
- Swift学习笔记(二十八)——Switch-Case的高级用法
- The Swift Programming Language学习笔记(十八)——可选链式调用
- Swift-扩展(Extensions)(十八)
- Swift中文教程(十八)类型转换
- Swift中文教程(十八) 类型检查
- Swift基础(二十八)UIPickerView
- 学习笔记(十八)
- 《汇编语言》学习(十八)
- 机器学习(十八)
- python学习(十八)
- linux下查看文件编码及修改编码
- Python爬虫积累
- 【BZOJ 2818】 gcd(附φ的线性筛法预处理)
- 当布局中如果出现多个文本并且颜色背景不同,我们怎么办
- 1、我的php自学笔记开始
- swift 学习这十八:宏()
- leetcode——Container With Most Water
- c++: vector
- 应用内跳转到App Store
- Swift 学习之二十:类型强转(+、-、*、/)
- hdu acm 1016
- wol 远程开机编译源码
- 互联网圈子,黄进磊竟然把它解释的如此霸气!
- windows远程桌面访问ubuntu