swift 学习这十八:宏()
来源:互联网 发布:人工智能服务平台 编辑:程序博客网 时间:2024/05/16 01:02
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 MacrosWhere 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 definelet kCommonAPI = "http://xxxxxxx"
main.swift:
import Foundationprintln(kCommonAPI)
result:
http://xxxxxxxProgram 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学习(十八)
- java 字符串转为整型
- VC直方图统计
- C++库常用函数
- DSPLINk channel组件与message组件的小结
- 【判断蜂蜜真伪的简单方法】
- swift 学习这十八:宏()
- Visual Studio 2010下配置PC-Lint 9.0i
- RGB颜色查询对照表
- DSPLINK DEMO解析之READWRITE
- Google 的开源技术protobuf 简介与例子
- 8888帅气图片网络红人打造第一期
- IOS开发(103)之后台处理
- 交通灯管理系统学习总结
- DSPLINK DEMO解析之RING_IO