Swift指定桥接头文件到swiftc
示例
该-import-objc-header标志指定swiftc要导入的标头:
//defs.h
struct Color {
int red, green, blue;
};
#define MAX_VALUE 255//演示迅捷
extension Color: CustomStringConvertible { //C结构的扩展
public var description: String {
return "Color(red: \(red), green: \(green), blue: \(blue))"
}
}
print("MAX_VALUE is: \(MAX_VALUE)") //C宏成为常量
let color = Color(red: 0xCA, green: 0xCA, blue: 0xD0) //C结构初始化器
print("The color is \(color)")$ swiftcdemo.swift-import-objc-header defs.h && ./demo MAX_VALUE is: 255 The color is Color(red: 202, green: 202, blue: 208)
热门推荐
10 病人祝福语老师寄语简短
11 新娘生孩子祝福语简短
12 婆婆66岁祝福语简短
13 今天孩子高考祝福语简短
14 送彩票生日祝福语简短
15 分别祝福语简短情话英文
16 画室揭牌仪式祝福语简短
17 女友妈妈生日祝福语简短
18 离别赠言离职祝福语简短