在子类化时混合objective-c和swift [英] mixing objective-c and swift when subclassing
问题描述
我有一个用Swift编写的UIViewController子类,叫做'BaseViewController'。我现在有一个名为'ViewController1'的'旧'视图控制器,用Objective-C编写,我想从'BaseViewController'继承。按照其他建议我导入了'Project-Swift.h'头文件。
I've got a subclass of UIViewController written in Swift called 'BaseViewController'. I now have an 'old' view controller called 'ViewController1' written in Objective-C that I want to inherit from 'BaseViewController'. Following other advice I have imported the 'Project-Swift.h' header file.
当像这样进行子类化时出现问题
My problem occurs when subclassing like this
#import <UIKit/UIKit.h>
#import "MyProject-Swift.h"
@interface ViewController1 : BaseViewController
@end
错误是:
不能使用objc_subclassing-restricted属性对类进行子类化
Cannot subclass a class with objc_subclassing-restricted attribute
它出现在@interface ...行上。
and it appears on the @interface ... line.
推荐答案
这篇关于在子类化时混合objective-c和swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!