I successfully mix and match Obj-C and Swift in an Xcode 7 project. However, I cannot figure out how to inherit the Swift class in the Objective-C class (and yes, I know about declaring this Swift class as @objc for visibility). In this case, the desired superclass of the Swift class MySwiftViewController is a subclass of UIViewController . So far, in Obj-C, I inherit directly from the UIViewController and do not get access to the features that I added to MySwiftViewController .
Here is what I understand:
- Declare the Obj-C class as an inheritance from something that should be in the .h file after the ':' character:
#import <UIKit/UIKit.h> @interface RootViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> @end
- To make Swift classes visible, i.e. #import ed:
#import "MyProject-Swift.h"
However, you cannot import the automatically generated Swift bridge header into the Obj-C .h file. You also cannot redirect an opaque superclass with @class . So, is this possible and how?
inheritance ios objective-c swift
Basezen
source share