是否可以使结构和/或类型符合@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导出
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。