Fixing crash in NotificationCenter event handler

This commit is contained in:
Selim Mustafaev 2024-10-25 23:58:36 +03:00
parent 807fa94e31
commit 9b37f46e33
2 changed files with 10 additions and 6 deletions

View File

@ -1653,7 +1653,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 136;
CURRENT_PROJECT_VERSION = 137;
DEVELOPMENT_TEAM = 46DTTB8X4S;
INFOPLIST_FILE = AutoCat/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
@ -1680,7 +1680,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 136;
CURRENT_PROJECT_VERSION = 137;
DEVELOPMENT_TEAM = 46DTTB8X4S;
INFOPLIST_FILE = AutoCat/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;

View File

@ -56,7 +56,11 @@ class CheckController: UIViewController, UITableViewDelegate, UISearchResultsUpd
}
self.history.delegate = self
NotificationCenter.default.addObserver(self, selector:#selector(self.calendarDayDidChange(_:)), name:NSNotification.Name.NSCalendarDayChanged, object:nil)
NotificationCenter.default.addObserver(forName: .NSCalendarDayChanged,
object: nil,
queue: .main,
using: calendarDayDidChange)
}
override func viewWillDisappear(_ animated: Bool) {
@ -118,9 +122,9 @@ class CheckController: UIViewController, UITableViewDelegate, UISearchResultsUpd
}
}
@objc private func calendarDayDidChange(_ notification : NSNotification) {
DispatchQueue.main.async {
self.historyDataSource.reload()
nonisolated private func calendarDayDidChange(_ notification : Notification) {
MainActor.assumeIsolated {
historyDataSource.reload()
}
}