我正在使用 NSOpenPanel 在我的应用程序上设置一个文件夹,但我将其作为文件夹“file://localhost/Users/juan/”的路径
这是我的代码:
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];
}
}];
}
我的问题是如何或我需要做什么来获得绝对路径,例如“/Users/juan/Desktop/”而没有文件:// localhost。
我真的很感激任何指示。