[英]Migrating from Swift 3.2 to Swift 4 I get an error using autosavesInPlace
In a macOS project I use autosavesInPlace in this way: 在macOS项目中,我以这种方式使用autosavesInPlace:
import Cocoa
class Document: NSDocument {
override class func autosavesInPlace() -> Bool {
return true
}
}
This worked until the project was in Swift 3.2 but when updating the project in Swift 4, I get this error: 在项目在Swift 3.2中运行之前,它一直有效,但是在Swift 4中更新项目时,出现此错误:
Method does not override any method from its superclass
方法不会覆盖其超类中的任何方法
How can I fix this? 我怎样才能解决这个问题?
Since Swift 4 autosavesInPlace
is a property (not a function), so you should override in this way: 由于Swift 4
autosavesInPlace
是一个属性(不是函数),因此您应该以这种方式覆盖:
class Document: NSDocument {
override class var autosavesInPlace: Bool {
return true
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.