Skip to content

Instantly share code, notes, and snippets.

Last active Sep 19, 2022
What would you like to do?
A first Cocoa app for OS X Tiger 10.4 using Xcode 3.1.4

Blog 2022/3/21

<- previous | index | next ->

A first Cocoa app for OS X Tiger 10.4 using Xcode 3.1.4

Getting my feet wet with Cocoa development for PowerPC Macs.

This app simply draws a blue window. Note that this does not require using Interface Builder.

Create a new Xcode project, then paste this into main.m:

#import <Cocoa/Cocoa.h>

@interface BlueView: NSView

@implementation BlueView
- (void)drawRect:(NSRect)rect {
    [[NSColor blueColor] setFill];
    [super drawRect:rect];

@interface AppListener: NSObject
- (void)applicationDidBecomeActive;

@implementation AppListener

- (void)applicationDidBecomeActive {
    NSLog(@"did become active.");
    NSWindow* window = [[NSApplication sharedApplication] keyWindow];
    NSLog(@"window: %@", window);
    NSView* view = [[BlueView alloc] init];
    [window setContentView:view];


int main(int argc, char *argv[])
    AppListener* listener = [[AppListener alloc] init];
    [[NSNotificationCenter defaultCenter]
        name:NSApplicationDidBecomeActiveNotification object:nil];
    return NSApplicationMain(argc,  (const char **) argv);


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment