Update template project for a new application

Use an application controller instead of embedding a window with a custom view in the nib.
This commit is contained in:
Allan Odgaard
2014-11-11 13:33:27 +01:00
parent 568fcd49cf
commit 26dead41ca
5 changed files with 421 additions and 822 deletions

View File

@@ -0,0 +1,2 @@
@interface ApplicationController : NSObject
@end

View File

@@ -0,0 +1,22 @@
#import "ApplicationController.h"
@interface ApplicationController () <NSApplicationDelegate, NSWindowDelegate>
@property (nonatomic) NSWindow* window;
@end
@implementation ApplicationController
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification
{
_window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 400, 400) styleMask:(NSTitledWindowMask|NSResizableWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask) backing:NSBackingStoreBuffered defer:NO];
_window.releasedWhenClosed = NO;
_window.delegate = self;
_window.title = @"New Application";
[_window center];
[_window makeKeyAndOrderFront:self];
}
- (void)windowWillClose:(NSNotification*)aNotification
{
[NSApp terminate:self];
}
@end

View File

@@ -1,4 +0,0 @@
@interface MyView : NSView
{
}
@end

View File

@@ -1,8 +0,0 @@
#import "MyView.h"
@implementation MyView
- (void)drawRect:(NSRect)aRect
{
NSEraseRect(aRect);
}
@end