Created
July 1, 2014 03:25
-
-
Save uranusjr/4ad7fddb2585edaba5c1 to your computer and use it in GitHub Desktop.
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
if (argc < 2) | |
{ | |
// Launch normally. | |
return; | |
} | |
NSString *path = [NSString stringWithUTF8String:argv[1]]; | |
path = [path stringByStandardizingPath]; // You should do this, BTW. | |
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) | |
{ | |
// Open the file. | |
return; | |
} | |
NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; | |
NSURL *appURL = [workspace URLForApplicationWithBundleIdentifier:@"com.uranusjr.macdown"]; | |
NSDictionary *configuration = @{ | |
NSWorkspaceLaunchConfigurationArguments: @[ | |
@"-defaultSavePath", path, | |
], | |
}; | |
[workspace launchApplicationAtURL:appURL | |
options:NSWorkspaceLaunchDefault | |
configuration:configuration | |
error:NULL]; // Fallback to normal launch on error? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment