获取系统根目录的NSURL

Getting NSURL of System Root Directory

我想获取根目录的NSURL。我试过这个:

NSURL *rootURL = [NSURL fileURLWithPath:@"/" isDirectory:YES];

但它打印

file://localhost/

我希望我的输出是

file:///

对这个简单的问题有什么帮助吗?

file://localhost/ 是有效的。我不知道 file:/// 是否也是有效的 url,但如果是,它们是相同的。

这应该有效:

NSURL *url = [NSURL URLWithString:@"file:///"];

它returns你想要的。