aka RedditBar, Mac OS X menu bar reddit client
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AppDelegate.m 1.3KB

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // AppDelegate.m
  3. // BaconBarHelper
  4. //
  5. // Created by Thomas Buck on 28.12.13.
  6. // Copyright (c) 2013 xythobuz. All rights reserved.
  7. //
  8. #import "AppDelegate.h"
  9. @implementation AppDelegate
  10. - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
  11. NSString *appName = [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"] stringByReplacingOccurrencesOfString:@"Helper" withString:@""];
  12. BOOL alreadyRunning = NO;
  13. NSArray *running = [[NSWorkspace sharedWorkspace] runningApplications];
  14. for (NSRunningApplication *app in running) {
  15. if ([[app bundleIdentifier] isEqualToString:appName]) {
  16. alreadyRunning = YES;
  17. }
  18. }
  19. if (!alreadyRunning) {
  20. NSMutableArray *pathComponents = [NSMutableArray arrayWithArray:[[[NSBundle mainBundle] bundlePath] pathComponents]];
  21. [pathComponents removeLastObject]; // /Applications/BaconBar.app/Contents/Library/LoginItems
  22. [pathComponents removeLastObject]; // /Applications/BaconBar.app/Contents/Library
  23. [pathComponents removeLastObject]; // /Applications/BaconBar.app/Contents
  24. [pathComponents removeLastObject]; // /Applications/BaconBar.app
  25. [[NSWorkspace sharedWorkspace] launchApplication:[NSString pathWithComponents:pathComponents]];
  26. }
  27. [NSApp terminate:nil];
  28. }
  29. @end