Search code examples
macoscocoansopenpanel

NSOpenPanel - Everything deprecated?


I've been trying to get a window to show up asking the person to choose a file, and I eventually did. The problem is, Xcode complains that the method I'm using is deprecated. I looked in the class reference, but everything under the "running panels" section has been deprecated as of Mac OS 10.6. Is there a different class I'm supposed to be using now?


Solution

  • As far as I know, you can use the runModal method like shown below:

    NSOpenPanel *openPanel = [[NSOpenPanel alloc] init];
    
    if ([openPanel runModal] == NSOKButton)
    {
        NSString *selectedFileName = [openPanel filename];
    }