在 Swift 的 macOS 应用程序中阻止 "Do you want to save the changes" 对话框
Preventing the "Do you want to save the changes" dialog in a macOS app in Swift
在基于文档的 macOS 项目中,我想避免
"Do you want to save the changes you made in the document “Untitled”? "如果不保存,您的更改将会丢失。"
留言。
我正在尝试实施此解决方案Preventing the "Save on Exit" dialogue on exit of a Cocoa Document Application
import Cocoa
class Document: NSDocument {
var myDoc = MyDoc()
func isDocumentEdited() -> Bool {
return false
}
}
但我收到错误:
Method 'isDocumentEdited()' with Objective-C selector
'isDocumentEdited' conflicts with getter for 'documentEdited' from
superclass 'NSDocument' with the same Objective-C selector
我该怎么做才能解决这个错误?
除非您是从 window class 调用 isDocumentEdited
,否则您可能想要这样做:
class Document: NSDocument {
var myDoc = MyDoc()
override var isDocumentEdited: Bool {
return false
}
}
在基于文档的 macOS 项目中,我想避免
"Do you want to save the changes you made in the document “Untitled”? "如果不保存,您的更改将会丢失。"
留言。
我正在尝试实施此解决方案Preventing the "Save on Exit" dialogue on exit of a Cocoa Document Application
import Cocoa
class Document: NSDocument {
var myDoc = MyDoc()
func isDocumentEdited() -> Bool {
return false
}
}
但我收到错误:
Method 'isDocumentEdited()' with Objective-C selector 'isDocumentEdited' conflicts with getter for 'documentEdited' from superclass 'NSDocument' with the same Objective-C selector
我该怎么做才能解决这个错误?
除非您是从 window class 调用 isDocumentEdited
,否则您可能想要这样做:
class Document: NSDocument {
var myDoc = MyDoc()
override var isDocumentEdited: Bool {
return false
}
}