[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GNUstep tutorial on Mac OS X?

From: Phillip Tamulonis
Subject: GNUstep tutorial on Mac OS X?
Date: Thu, 3 Jul 2003 11:32:42 -0400


I've been working through Nicola Pero's GNUstep tutorials on Mac OS X to gauge compatibility between the two systems.

The First GUI Application tutorial at http://www.gnustep.it/nicola/Tutorials/FirstGUIApplication/node11.html builds fine, but when I try to run it, all that comes up is an empty application menu.

I read in the Renaissance documentation that this is because Mac OS X automatically creates a default menu that overrides any declarations. I tried moving the menu declaration around in the example to no avail.

The example follows.


Phil T.

#include <Foundation/Foundation.h>
#include <AppKit/AppKit.h>
#include <GNUstep/GNUstep.h>

//#define AUTORELEASE(object)      [object autorelease]

@interface MyDelegate : NSObject
- (void) printHello: (id)sender;
- (void) applicationWillFinishLaunching: (NSNotification *)not;

@implementation MyDelegate : NSObject
- (void) printHello: (id)sender;
printf ("Hello!\n");

- (void) applicationWillFinishLaunching: (NSNotification *)not
  NSMenu *menu;

  menu = AUTORELEASE ([NSMenu new]);

  [menu addItemWithTitle: @"PrintHello"
        action: @selector (printHello:)
        keyEquivalent: @""];

  [menu addItemWithTitle: @"Quit"
        action: @selector (terminate:)
        keyEquivalent: @"q"];

  [NSApp setMainMenu: menu];

int main (int argc, const char **argv)
  [NSApplication sharedApplication];
  [NSApp setDelegate: [MyDelegate new]];
//  [NSApp run];
  return NSApplicationMain (argc, argv);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]