1.swift中调用oc
搜索Objective-C Bridging Header,导入头文件路径


在Header桥接文件中声明需要桥接的类



直接调用oc的方法
2.oc中调用swift
1.创建oc项目或已有的oc项目
2.导入swift文件或者创建swift文件(重点)
会有提示是否创建桥接文件一般的话会Create Bridging Header

创建之后Build Setting会多出一些Swift的分类(可不管)

3.Defines Module设为YES(重点)

4.接下来就可以写代码了(swift中代码有更新必须编译一下代码才会有提示)


接下来就可以愉快的玩耍了!!!
网友评论