Search code examples
objective-cswifttypedefcode-conversiontype-alias

Convert typedef to Swift


How do I convert this code to Swift

 typedef  UIViewController<CalendarViewControllerNavigation> CalendarViewController;

tried to find solution everywhere but seems I can't find a reference to this.


Solution

  • In Swift 4 you can use:

    typealias CalendarViewController = UIViewController & CalendarViewControllerNavigation
    

    Which uses the new protocol composition type. Also see SE-156.