Created
July 22, 2013 05:24
-
-
Save danmartyn/6051464 to your computer and use it in GitHub Desktop.
This is a cocoa method for restarting a mac app
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
+(void)restart:(id)sender | |
{ | |
NSString *restartScript = @"while ps -p $1 > /dev/null; do sleep 0.1; done; open \"$2\""; | |
NSArray *arguments = [NSArray arrayWithObjects: | |
@"-c", restartScript, | |
@"", | |
[NSString stringWithFormat:@"%d",[[NSProcessInfo processInfo] processIdentifier]], | |
[[NSBundle mainBundle] bundlePath], | |
nil]; | |
[NSTask launchedTaskWithLaunchPath:@"/bin/sh" arguments:arguments]; | |
[NSApp terminate:self]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment