I've created a NSWindow
with a PDFView
in xib file, I created a controller called MainController, there, I created a ibaction -(IBAction) openFileAction:(id) sender
, it uses the method
-(void) openFile:(NSString *) path{
NSLog(@"Opening File %@",path);
PDFDocument *pdfDoc = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:path]];
[pdfView setDocument: pdfDoc];
}
I linked the open menu item to openFileAction
and pdf file is shown properly in PDFView after the click.
I'm doing a logic to receive a command line argument
-(MainController *) init{
[super init];
NSArray *myArgs = [[NSProcessInfo processInfo] arguments];
NSLog(@"pdf view %@", pdfView);
if ([myArgs count] >= 2 ){
[self openFile:[myArgs objectAtIndex:1]];
}
return self;
}
As you can see, I did an override in default constructor and in this context the pdfView is null then the file is not opened after the application/main Window load.
My question is, how can I open a pdf in a PDFView after the application load? Is there any hook to use after UI load?