Open new document from within another document.
Open new document from within another document.
- Subject: Open new document from within another document.
- From: Jeffrey Andrews <email@hidden>
- Date: Mon, 11 Jan 2010 08:43:27 -0500
I am stumped. I am trying to open another document from within a
document. My AppController implements the delegate method
-(BOOL) application:(NSApplication*) sender openFile:(NSString*)path
{
NSLog(@"AppController - application:openFile - %@", path);
NSDocumentController* dc = [NSDocumentController
sharedDocumentController];
id doc = [dc openDocumentWithContentsOfURL:[NSURL URLWithString:path]
display:YES];
return (doc != nil);
}
From within MyDocument.m
I have a method like below
-(void)openSelectedFile
{
// if nothing selected, return
if([tableView numberOfSelectedRows] != 1)
return;
NSLog(@"openSelectedFile");
NSDictionary* dict = [entries objectAtIndex:[tableView selectedRow]];
NSString* tempDirectory = NSTemporaryDirectory();
NSLog(@"temp directory = %@", tempDirectory);
NSMutableArray* filenames = [[NSMutableArray alloc] initWithObjects:
[dict valueForKey:@"filename"], nil];
if([self fileIsSupported:[dict valueForKey:@"filename"]])
{
[extractor extractFiles:filenames toDirectory:tempDirectory];
NSString* tmpFilename = [tempDirectory
stringByAppendingPathComponent:[dict valueForKey:@"filename"]];
NSApplication* app = [NSApplication sharedApplication];
[[app delegate] application:app openFile:tmpFilename];
}
[filenames release];
}
How else should I handle opening another window with the file specified?
BTW: I can drag and drop onto my icon. I can Open and Open Recent
from the Menu just fine.
This is the only issue I have trying to open a document. Oh, and just
to cover my bases, I did make sure
that the file exists and is accessible.
Thanks,
Jeff
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden