[英]Swift framework in ObjectiveC project
I have an older application made in Objective C. I want to add more features to it and I want to continue and write code in Swift (in which i'm new) from now on in this project. 我在Objective C中有一个较旧的应用程序。我想向它添加更多功能,并且我想从现在开始在该项目中继续使用Swift(我是新手)编写代码。
I want to add this framework https://github.com/xmartlabs/XLPagerTabStrip and add some tabs using it. 我想添加此框架https://github.com/xmartlabs/XLPagerTabStrip并使用它添加一些选项卡。 The tabs I want to add are some VC-s made in ObjectiveC.
我要添加的选项卡是一些在ObjectiveC中制作的VC。
I need to add some Swift code like shown below to the EmbeddedVC-s and I don't know how that is possible. 我需要将一些如下所示的Swift代码添加到EmbeddedVC-s中,但我不知道怎么可能。
func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
return IndicatorInfo(title: "My Child title")
}
Is it possible to use this framework in my project? 是否可以在我的项目中使用此框架?
Thanks! 谢谢! :)
:)
To add Swift into an Objective-C file, make sure to import "ProjectName-Swift.h" at the beginning of the Objective-C class. 要将Swift添加到Objective-C文件中,请确保在Objective-C类的开头导入“ ProjectName-Swift.h”。 Remember to tag your Swift classes with @objc, or make sure the Swift class inherets from NSObject.
请记住使用@objc标记Swift类,或确保来自NSObject的Swift类继承。
More info here: Can't use Swift classes inside Objective-C 更多信息在这里: 无法在Objective-C中使用Swift类
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.