每当我选择包含符号链接的路径时,NSOpenPanel都会返回已解析的路径。 e.g:
ln -s /Users/myuser/some/path/here /Users/myuser/mylink
现在我选择文件/Users/myuser/mylink/file.txt
,但[[panel URLs] objectAtIndex:0]
为/Users/myuser/some/path/here/file.txt
。
如何让NSOpenPanel返回我选择的内容(不解析符号链接)?
答案 0 :(得分:2)
将resolvesAliases
设为NO
:
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
oPanel.resolvesAliases = NO;
if ([oPanel runModal] == NSOKButton) {
NSLog([[[oPanel URLs] objectAtIndex:0] absoluteString]);
}