Is it possible to make a struct
and/or typealias
conform to @objc
? I wish to create optional protocol functions, one returns a struct
, the other a typealias
.
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
}
}
protocol
@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
}
You can't export typealiases to Objective-C. And you can't do it for tuples. But, about typealias
, it's still possible to write Obj-C typedef
for some struct and use it from Swift, it will be exported as typealias
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With