
点击确认,x-code会自动弹出一个提示框,点击create按钮即可。

如此项目中会自动生成一个(项目名-Bridging-Header.h)的文件,在这个文件中引入对应的oc项目的头文件,即可在swift代码中调用oc类,例如
在项目名-Bridging-Header.h文件中导入

回到创建的swift类中(TTLInternetSensationViewController.swift),可以调用刚刚所引入的HomePageViewController类,这里用跳转页面作为代码示例:

同样,在oc中调用swift的类,只需要在oc代码中导入一个(类名-Swift.h)的一个头文件就能使用,为了引用方便,我将其放入了全局的头文件中:

例举代码,如下

以上
网友评论