如何在基于Swift的项目中使用基于Objective-C的框架?

时间:2018-01-08 02:58:13

标签: ios objective-c swift

我有一个基于Objective-C的可可豆荚框架。该框架有一个带有XIP视图控制器的类。我想从基于Swift的项目访问此控制器。以下代码是Objective-C代码。我需要在基于Swift的项目中使用它。

ViewController * viewController = [[ViewController alloc] initWithNibName:@“VController” bundle:nil];
viewController.delegate = self;
viewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[vc presentViewController: viewController animated:true completion:nil];

1 个答案:

答案 0 :(得分:1)

简单只需遵循一些步骤就可以做到了

我有一个项目,我在我的swift项目中使用RIOInterface.h Obj-c

第1步 - 只需在Swift Project中添加Objective c文件

我在项目中添加了RIOinterface.h和.mm

enter image description here

第2步当您只需拖放Obj-c Classes时,弹出窗口将显示为

enter image description here

- >单击是

第3步 - 现在在创建的桥接类中导入Obj-C标头

enter image description here

第4步 - 您已完成配置步骤现在,使用该课程的时间

as,我为该类创建了一个Object

enter image description here

现在将它与下面的

创建的对象一起使用

enter image description here

您在Swift中访问了Objective-C代码