private var documentObserver: NSObjectProtocol?
override func viewDidLoad() {
super.viewDidLoad()
documentObserver = NotificationCenter.default.addObserver(
forName: Notification.Name.UIDocumentStateChangedNotification ,
object: document,
queue: OperationQueue.main,
using: { notification in
print("docuemntState Changed to \(self.document!.documentState)")
}
)
}
我正在尝试这样做,但是Xcode向我显示错误:
类型'Notification.Name'(aka'NSNotification.Name')没有成员 'UIDocumentStateChangedNotification'
答案 0 :(得分:0)
您要查找的通知名称是UIDocument
的静态常量
UIDocument.stateChangedNotification