One Quickie


Using an NSOpenPanel (General->General)
    NSOpenPanel *panel = [NSOpenPanel openPanel];

    [panel setPrompt: @"Stuff for the Choose Button"];

    [panel beginSheetForDirectory: nil
           file: nil
           types: [NSArray arrayWithObject: @"buf"] // or other file types
           modalForWindow: window
           modalDelegate: self
           didEndSelector: @selector(openPanelDidEnd:returnCode:contextInfo:)
           contextInfo: nil];
and the didEndSelector implementation looks kinda like this:
- (void) openPanelDidEnd: (NSOpenPanel *) sheet
              returnCode: (int) returnCode
             contextInfo: (void *) context
{
    if (returnCode == NSOKButton) {
        NSArray *fileNames = [sheet filenames];

        NSLog (@"wooOOooot! %@", [fileNames objectAtIndex: 0]);
    }

} // openPanelDidEnd



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com