swift – 如何使struct和typealias符合@objc
发布时间:2020-12-14 04:34:08 所属栏目:百科 来源:网络整理
导读:是否可以使结构和/或类型符合@objc?我希望创建可选的协议函数,一个返回一个结构,另一个返回一个类型. public typealias SwiperData = (image: UIImage,title: String)public struct SwiperPeekViewControllers{ public var parentViewController: UIViewCon
是否可以使结构和/或类型符合@objc?我希望创建可选的协议函数,一个返回一个结构,另一个返回一个类型.
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导出
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |