macOS文件选择

1
2
3
4
5
6
7
8
9
10
11
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
//是否可以选择文件夹
[openPanel setCanChooseDirectories:YES];
//是否可以选择文件
[openPanel setCanChooseFiles:NO];
BOOL okButtonPressed = ([openPanel runModal] == NSModalResponseOK);
//NO表示用户取消 YES表示用户做出选择
if(okButtonPressed)
{
NSLog(@"%@", path);
}