我想让用户选择一个目录来保存文件。但是如何确保 url 是目录而不是文件?
NSOpenPanel* panel = [NSOpenPanel openPanel];
[panel setCanChooseDirectories:YES];
[panel setCanCreateDirectories:YES];
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result){
if (result == NSFileHandlingPanelOKButton) {
NSArray* urls = [panel URLs];
for (NSURL *url in urls) {
//here how to judge the url is a directory or a file
}
}
}];