diff --git a/Image Opener/Image_OpenerAppDelegate.h b/Image Opener/Image_OpenerAppDelegate.h index c5fd68c..2f7e64f 100644 --- a/Image Opener/Image_OpenerAppDelegate.h +++ b/Image Opener/Image_OpenerAppDelegate.h @@ -10,7 +10,8 @@ @interface Image_OpenerAppDelegate : NSObject { @private - NSWindow *window; + NSWindow *_window; + NSDocumentController *_controller; } @property (assign) IBOutlet NSWindow *window; diff --git a/Image Opener/Image_OpenerAppDelegate.m b/Image Opener/Image_OpenerAppDelegate.m index c61c128..81fb653 100644 --- a/Image Opener/Image_OpenerAppDelegate.m +++ b/Image Opener/Image_OpenerAppDelegate.m @@ -11,13 +11,21 @@ @implementation Image_OpenerAppDelegate -@synthesize window; +@synthesize window = _window; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + _controller = [[NSDocumentController sharedDocumentController] retain]; // Insert code here to initialize your application } +- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename +{ + WindowController *controller; + controller = [WindowController controllerWithFilePath: filename]; + return YES; +} + -(IBAction)openDocument:(id)sender { NSOpenPanel *panel; @@ -35,7 +43,6 @@ if (result == 1) { - WindowController *controller; NSURL *url = [[panel URLs] lastObject]; NSString *path = [url isFileURL] ? [url path] : nil; @@ -43,7 +50,9 @@ if (path) { - controller = [WindowController controllerWithFilePath: path]; + [self application: nil openFile: path]; + + [_controller noteNewRecentDocumentURL: url]; } }