NSOpenPanel - Everything deprecated?

前端 未结 3 1729
花落未央
花落未央 2021-02-07 23:43

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.

3条回答
  •  遇见更好的自我
    2021-02-08 00:15

    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];
    }
    

提交回复
热议问题