如何解析NSOpenPanel中的符号链接?

时间:2015-05-23 01:46:50

标签: objective-c nsopenpanel

每当我选择包含符号链接的路径时,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返回我选择的内容(不解析符号链接)?

1 个答案:

答案 0 :(得分:2)

resolvesAliases设为NO

NSOpenPanel *oPanel = [NSOpenPanel openPanel];
oPanel.resolvesAliases = NO;

if ([oPanel runModal] == NSOKButton) {
    NSLog([[[oPanel URLs] objectAtIndex:0] absoluteString]);
}