Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // AppDelegate.h & AppDelegate.m are sample code generated by XCode Cocoa
- // app wizard.
- // AppDelegate.h
- @interface AppDelegate : NSObject <NSApplicationDelegate>
- {
- // Instance variable ensures that ARC does not clean it up
- NSStatusItem *theItem;
- }
- - (void) activateStatusMenu;
- - (void) activateGUI;
- - (void) quitApp;
- @end
- // AppDelegate.m
- @interface AppDelegate ()
- @property (weak) IBOutlet NSWindow *window;
- @end
- @implementation AppDelegate
- - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
- // Insert code here to initialize your application
- [self activateStatusMenu];
- }
- - (void)applicationWillTerminate:(NSNotification *)aNotification {
- // Insert code here to tear down your application
- }
- /**
- * Create the Status icon & its menu
- */
- - (void)activateStatusMenu
- {
- NSStatusBar *bar = [NSStatusBar systemStatusBar];
- theItem = [bar statusItemWithLength:NSSquareStatusItemLength];
- // Requires project to have asset named Status, which consists of one 16x16 icon
- [[theItem button] setImage: [NSImage imageNamed:@"Status"]];
- [theItem setHighlightMode:YES];
- NSMenu* menu = [[NSMenu alloc] init];
- NSMenuItem* item = [[NSMenuItem alloc] init];
- [item setTitle:@"StatusBarProgram"];
- [item setAction:@selector(activateGUI)];
- [menu addItem: item];
- item = [[NSMenuItem alloc] init];
- [item setTitle:@"Quit"];
- [item setAction:@selector(quitApp)];
- [menu addItem: item];
- [theItem setMenu:menu];
- }
- - (void) activateGUI
- {
- NSLog(@"Launch GUI");
- }
- - (void) quitApp
- {
- [NSApp terminate:self];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement