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 protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to