I have a button on click of which Safari Preferences should load. Once Safari Preferences has loaded, I want my apllication to get terminated. But the following code does not wait for the Safari Preferences to get loaded before terminating the app. How do I fix this?
Code Block @IBAction func openSafariExtensionPreferences(_ sender: AnyObject?) { SFSafariApplication.showPreferencesForExtension(withIdentifier: extensionBundleIdentifier) { [self] error in guard error == nil else { self.alert(title: "Error", message: "Safari preferences could not be opened.", buttonText: "Okay") return } DispatchQueue.main.async { safariPreferencesButton.isEnabled = false NSApplication.shared.terminate(nil) } } }