oc swift 混编
2016-03-14 本文已影响347人
August24
在 oc
或 swift
项目中新建另一种语言文件时,xcode
会提示产生一个桥接文件,当我们点击同意后查看产生的这个桥接文件,发现
// Use this file to import your target's public headers that you would like to expose to Swift.
首先,我们检查Build Setting中这个桥接文件是否被正确添加,被正确添加后:
-
swift使用OC
- 我们在这个桥接文件中添加
#import "oc文件.h"
使得所有swift
类中能够用swift
语法使用这个被添加的oc
类。
- 我们在这个桥接文件中添加
-
OC使用swift
- 在oc类中
#import "项目名称-Swift.h"
,就可以用OC语法使用所有swift类
- 在oc类中


