--- a/PDFViewer/appdelegate/AppDelegate.m
+++ b/PDFViewer/appdelegate/AppDelegate.m
@@ -8,14 +8,9 @@
#import "AppDelegate.h"
-@interface AppDelegate ()
-
-@end
-
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
- // Insert code here to initialize your application
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
@@ -26,4 +21,35 @@
return TRUE;
}
+- (BOOL) application:(NSApplication *)sender openFile:(NSString *)filename {
+ window = [[[NSApplication sharedApplication] windows] objectAtIndex:0];
+ controller = (ViewController*) [window contentViewController];
+
+ NSURL *url = [[NSURL alloc] initFileURLWithPath:filename];
+ BOOL status = [[controller pdfViewer] loadUrl: url];
+
+ if (!status) {
+ [[controller pdfViewer] speak:(NSMutableString*)@"Das Dokument konnte nicht geladen werden"];
+ } else {
+ [[controller pdfViewer] startSpeaking:nil];
+ }
+
+ return status;
+}
+
+- (void) application:(NSApplication *)sender openFiles:(NSArray<NSString *> *)filenames {
+ window = [[[NSApplication sharedApplication] windows] objectAtIndex:0];
+ controller = (ViewController*) [window contentViewController];
+
+ NSString *filename = [filenames objectAtIndex:0];
+ NSURL *url = [[NSURL alloc] initFileURLWithPath:filename];
+ BOOL status = [[controller pdfViewer] loadUrl: url];
+
+ if (!status) {
+ [[controller pdfViewer] speak:(NSMutableString*)@"Das Dokument konnte nicht geladen werden"];
+ } else {
+ [[controller pdfViewer] startSpeaking:nil];
+ }
+}
+
@end