Created
June 4, 2010 15:59
-
-
Save mkhl/425597 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Restart your Cocoa application using Sparkle | |
// Author: Marc Charbonneau | |
// Source: http://blog.mbcharbonneau.com/2010/06/03/restart-your-cocoa-application-using-sparkle/ | |
NSString *launcherSource = [[NSBundle bundleForClass:[SUUpdater class]] pathForResource:@"relaunch" ofType:@""]; | |
NSString *launcherTarget = [NSTemporaryDirectory() stringByAppendingPathComponent:[launcherSource lastPathComponent]]; | |
NSString *appPath = [[NSBundle mainBundle] bundlePath]; | |
NSString *processID = [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]]; | |
[[NSFileManager defaultManager] removeItemAtPath:launcherTarget error:NULL]; | |
[[NSFileManager defaultManager] copyItemAtPath:launcherSource toPath:launcherTarget error:NULL]; | |
[NSTask launchedTaskWithLaunchPath:launcherTarget arguments:[NSArray arrayWithObjects:appPath, processID, nil]]; | |
[NSApp terminate:sender]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment