How to reference or call a view controller written in Swift from another controller written in Objective-C?
Apparently it's quite easy.
- You have to first make sure you're prepending your class declaration with
@objc
so that it's available to your Objective-C ones.
For example:
import Foundation
// Belongs to target 'TestProject'
@objc class SwiftController: UIViewController {
//... truncated
}
Now you simply have to import the name of your target (that the swift controller belongs to), appended with
'-Swift.h'
—exposing its interface—like so:#import "TestProject-Swift.h"