Last active
August 29, 2015 14:01
-
-
Save lattejed/87e39688a864b6c94401 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Controller.m | |
| // | |
| // Created by Matthew Smith on 4/21/14. | |
| // Copyright (c) 2014 LatteJed. All rights reserved. | |
| // | |
| #import "Controller.h" | |
| #import "Model.h" | |
| @interface Controller () | |
| @property (nonatomic, weak) IBOutlet NSButton* openFileButton; | |
| @property (nonatomic, weak) IBOutlet FileView* fileView; | |
| @property (nonatomic, strong) Model* model; | |
| @end | |
| @implementation Controller | |
| - (void)awakeFromNib; | |
| { | |
| [self.openFileButton setActionBlock:^{ | |
| NSOpenPanel *panel = [NSOpenPanel openPanel]; | |
| [panel beginSheetModalForWindow:[[self view] window] | |
| completionHandler:^(NSInteger result) { | |
| if (result == NSFileHandlingPanelOKButton) | |
| { | |
| self.model = [Model new]; | |
| self.model.url = [[panel URLs] firstObject]; | |
| } | |
| }]; | |
| }]; | |
| [[NSNotificationCenter defaultCenter] | |
| addObserverForName:kNotificationURLDidUpdate | |
| object:nil | |
| queue:nil | |
| usingBlock:^(NSNotification *note) { | |
| if ([self.model url]) | |
| { | |
| [self.fileView setFileWithURL:self.model.url]; | |
| } | |
| }]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment