是否可以使结构和/或类型符合@objc?我希望创建可选的协议函数,一个返回一个结构,另一个返回一个类型. public typealias SwiperData = (image: UIImage, title: String)public struct SwiperPeekViewControllers{
public typealias SwiperData = (image: UIImage, title: String)
public struct SwiperPeekViewControllers{
public var parentViewController: UIViewController!
public var contentViewController: UIViewController!
public init(parentVC: UIViewController, contentVC: UIViewController){
parentViewController = parentVC
contentViewController = contentVC
}
}
协议
@objc public protocol SwiperPeekViewDelegate: class{
func didUndoAction(index: Int, dataSource: SwiperData)
// Method cannot be a member of an @objc protocol because the type of the parameter 2 cannot be represented in Objective-C
func swiperPeekViewControllers()->SwiperPeekViewControllers
func swiperPeekViewSize()->CGSize
}
您不能将typealiases导出到Objective-C.你不能为元组做这件事.但是,关于typealias,仍然可以为某些结构编写Obj-C typedef并从Swift中使用它,它将作为typealias导出
