ios - Inherit from a Swift class in Objective C -
i'm mixing , matching obj-c , swift in xcode 7 project. however, can't seem figure out how, in objective c class, inherit swift class (and yes know declaring swift class @objc visibility). in case desired swift superclass myswiftviewcontroller subclass of uiviewcontroller. now, in obj-c, i'm inheriting directly uiviewcontroller , not gaining access capabilities added in myswiftviewcontroller.
here's understand:
-- declare obj-c class inheriting something, must in .h file after ':':
#import <uikit/uikit.h> @interface rootviewcontroller : uiviewcontroller <uitableviewdatasource, uitableviewdelegate> @end -- make swift classes visible, #imported:
#import "myproject-swift.h" however, cannot import swift auto-generated bridging header obj-c .h file. cannot forward-declare opaque superclass @class. so, possible , how?
unfortunately, it's not possible subclass swift class in objective-c. straight docs:
you cannot subclass swift class in objective-c.
see apple's guide on interoperability more details on can , cannot access objective-c.
Comments
Post a Comment