我正在尝试将值从swift类传递到目标C类,但是在swift类中创建的委托无法从目标类中识别出来。

速成班:

protocol ChildViewControllerDelegate
{
 func childViewControllerResponse(parameter)
}

class ChildViewController:UIViewController
{
var delegate: ChildViewControllerDelegate?
}


目标C类:

#import "Project-Swift.h"
@interface MainViewController()<ChildViewControllerDelegate>
{

// Define Delegate Method
func childViewControllerResponse(parameter)
{
}

}


目标C类无法检测到委托。我将如何解决此问题或我做错了什么?

最佳答案

使用@objc使ChildViewControllerDelegate对Objective-C可见,即

@objc protocol ChildViewControllerDelegate {
    func childViewControllerResponse(parameter: String)
}


根据您的要求更改parameter类型。

关于objective-c - 我将如何实现委托(delegate)以将值从子swift类传递到父 objective-c 类?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58745989/

10-12 00:31
查看更多