Created
May 2, 2017 19:49
-
-
Save mminer/2c5ab47a45f5172e5793353888c1687b to your computer and use it in GitHub Desktop.
Extension function to restart a Cocoa application.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AppKit | |
extension NSApplication { | |
/// Restarts the application. | |
func restart() { | |
let process = Process() | |
process.launchPath = "/bin/sh" | |
process.arguments = ["-c", "sleep 1; open '\(Bundle.main.bundlePath)'"] | |
process.launch() | |
terminate(nil) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment