I'm successfully mixing and matching Obj-C and Swift in an Xcode 7 project. However, I can't seem to figure out how, in an Objective C class, to inherit from a Swift class (and yes I know about declaring that Swift class as @objc
for visibility). In this case the desired Swift superclass MySwiftViewController
is a subclass of UIViewController
. For now, in Obj-C, I'm inheriting directly from UIViewController
and not gaining access to the capabilities I added in MySwiftViewController
.
Here's what i understand:
-- To declare an Obj-C class as inheriting from something, that must be in the .h file after the ':':
#import <UIKit/UIKit.h>
@interface RootViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
@end
-- To make Swift classes visible, that is #import
ed:
#import "MyProject-Swift.h"
However, you cannot import the Swift auto-generated bridging header into the Obj-C .h file. You also cannot forward-declare an opaque superclass with @class
. So, is this possible and how?