まず最初に
「UIApplicationDidEnterBackground」は「UIApplication.didEnterBackgroundNotification」に名前が変更されました
そして私が点を打つと、
型 'Notification.Name' (別名 'NSNotification.Name') にはメンバー 'UIApplication' がありません
func listenForBackgroundNotification() {
observer = NotificationCenter.default.addObserver(forName: Notification.Name.UIApplicationDidEnterBackground, object: nil, queue: OperationQueue.main) { [weak self] _ in
if let weakSelf = self {
if weakSelf.presentedViewController != nil {
weakSelf.dismiss(animated: true, completion: nil)
}
weakSelf.descriptionTextView.resignFirstResponder()
}
}
}
ベストアンサー1
変化
forName: Notification.Name.UIApplicationDidEnterBackground
に
forName: UIApplication.didEnterBackgroundNotification