Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.m
- // hello
- //
- // Created by Youssef Gamil on ٢٩/٤/٢٠١١.
- // Copyright 2011 __MyCompanyName__. All rights reserved.
- //
- #import <Cocoa/Cocoa.h>
- #include <AppKit/AppKit.h>
- #import <Foundation/Foundation.h>
- @interface MyDelegate : NSObject {
- NSWindow *myWindow;
- }
- - (void) createMenu;
- - (void) createWindow;
- - (void) applicationWillFinishLaunching: (NSNotification *)not;
- - (void) applicationDidFinishLaunching: (NSNotification *)not;
- @end
- @implementation MyDelegate : NSObject
- - (void) dealloc {
- // RELEASE (myWindow);
- [myWindow dealloc];
- }
- - (void) createMenu {
- NSMenu *menu;
- menu=[NSMenu alloc];
- // menu = AUTORELEASE ([NSMenu new]);
- [menu addItemWithTitle: @"Quit" action: @selector (terminate:) keyEquivalent: @"q"];
- [NSApp setMainMenu: menu];
- }
- - (void) createWindow {
- NSRect rect = NSMakeRect (100, 100, 200, 200);
- unsigned int styleMask = NSTitledWindowMask | NSMiniaturizableWindowMask;
- myWindow=[NSWindow alloc];
- myWindow = [myWindow initWithContentRect:rect styleMask:styleMask backing:NSBackingStoreBuffered defer:NO];
- [myWindow setTitle: @"This is a test window"];
- }
- - (void) applicationWillFinishLaunching: (NSNotification *)not {
- [self createMenu];
- [self createWindow];
- }
- - (void) applicationDidFinishLaunching: (NSNotification *)not;
- {
- [myWindow makeKeyAndOrderFront: nil];
- }
- @end
- int main(int argc, char *argv[])
- {
- NSRect rect = NSMakeRect (100, 100, 200, 200);
- unsigned int styleMask = NSTitledWindowMask | NSMiniaturizableWindowMask;
- NSWindow *myWindow;
- myWindow=[NSWindow alloc];
- myWindow = [myWindow initWithContentRect:rect styleMask:styleMask backing:NSBackingStoreBuffered defer:NO];
- [myWindow setTitle: @"This is a test window"];
- [NSApp setDelegate: [MyDelegate new]];
- return NSApplicationMain(argc, (const char **) argv);
- }
Advertisement
Add Comment
Please, Sign In to add comment