[英]Use swift classes in Objective-c
I'm working with obj-C app, I need to integrate Clover Payment which are swift protocols.我正在使用 obj-C 应用程序,我需要集成 Clover Payment,它们是 swift 协议。 I have installed clover pods from https://github.com/clover/remote-pay-ios
我已经从https://github.com/clover/remote-pay-ios安装了三叶草豆荚
how to use swift protocols in obj-C?如何在 obj-C 中使用 swift 协议? I have done this:
我已经这样做了:
@class ICloverConnector;
@interface ViewPayment: UIViewController
{
ICloverConnector *cc;
}
#import "ProjectName-Swift.h"
public protocol ICloverConnector : AnyObject {
func addCloverConnectorListener(_ cloverConnectorListener:ICloverConnectorListener) -> Void
func initializeConnection() -> Void
}
How do I call these two functions from Obj-C class ?我如何从 Obj-C 类中调用这两个函数?
You need to use forward declarations.您需要使用前向声明。 See here:
看这里:
https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/importing_swift_into_objective-c https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/importing_swift_into_objective-c
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.