这是我的代码:
class CustomAlertAction: UIAlertAction {
init(title : String) {
super.init(title: title, style: UIAlertActionStyle.Default) { (action) -> Void in
}
}
}
但是我得到了以下编译错误:
必须调用超类“UIAlertAction”的指定初始化程序
我知道 UIAlertAction 的指定初始化程序是 init()。但是 UIAlert 的 init(title, style, handler) 不会调用它指定的初始化器 init() 吗?
任何想法?谢谢
PS:基于苹果的文档:
指定初始化器必须从其直接超类中调用指定初始化器。”
这是否意味着不允许在 Swift 中继承 UIAlertAction?在 Objective-C 中这样做是没有问题的。
我之所以要创建 UIAlertAction 的子类,是因为我想添加一个 ReactiveCocoa 命令作为操作。