此代码在 Playground 中有效,但是当我在 Xcode 7.2 的项目中定义它时出现编译错误
这是我的游乐场截图 https://goo.gl/yJ4Q75
错误是:方法没有覆盖超类中的任何方法
public class A {
private func myUnavailableMethod() {
print("A. private func myUnavailableMethod()")
}
}
public class B : A {
override func myUnavailableMethod() {
print("B. func myUnavailableMethod()")
}
}
尝试覆盖方法时,此 Playground 的动机是一个错误,编译器抱怨为“不可用”
class MySFSafariViewController: SFSafariViewController {
override init() {
}
}
---- 发现他们如何将方法标记为不可用。
跳转到 Objective C 声明时。
@interface SFSafariViewController : UIViewController
/*! @abstract The view controller's delegate */
@property (nonatomic, weak, nullable) id<SFSafariViewControllerDelegate> delegate;
****- (instancetype)init NS_UNAVAILABLE;****