我正在使用NSOpenPanel在我的应用程序上设置一个文件夹,但我得到这个文件夹的路径“file:// localhost/Users/juan/“使用NSOpenPanel获取文件夹位置删除文件:// localhost
这是我的代码:
NSOpenPanel * setDirectory = [NSOpenPanel openPanel];
setDirectory.canChooseFiles=NO;
setDirectory.canCreateDirectories=YES;
setDirectory.canChooseDirectories=YES;
setDirectory.directoryURL=_path;
[setDirectory beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
NSLog(@" results %ld", result);
if (NSFileHandlingPanelCancelButton){
NSLog(@"cancel");
}
if (NSFileHandlingPanelOKButton) {
self.path = [[setDirectory URLs] objectAtIndex:0];
}
}];
}
我的问题是如何或我需要做的就是绝对路径,如什么‘/用户/胡安/桌面/’无文件://本地主机。
我真的很欣赏任何指针。
如果用户选择多个项目有意义,为什么只处理用户选择中的一个随机项目?如果没有意义,为什么不关掉'allowedMultipleSelection'? –