Objective c 试图从字符串中获取绝对Url?
我有以下url作为字符串Objective c 试图从字符串中获取绝对Url?,objective-c,cocoa,Objective C,Cocoa,我有以下url作为字符串 /Users/username/Documents/ 我需要把它转换成 file:///localhost/Users/username/Documents/ 所以我可以在NSOpenPanel中将其用作路径参数。但我不知道怎么做?有什么办法吗?我知道如何从绝对->正常,但不是相反。您需要fileURLWithPath,如下所示: [NSURL fileURLWithPath:@"/Users/username/Documents/"]; 您需要fileURLWith
/Users/username/Documents/
我需要把它转换成
file:///localhost/Users/username/Documents/
所以我可以在NSOpenPanel中将其用作路径参数。但我不知道怎么做?有什么办法吗?我知道如何从绝对->正常,但不是相反。您需要fileURLWithPath,如下所示:
[NSURL fileURLWithPath:@"/Users/username/Documents/"];
您需要fileURLWithPath,如下所示:
[NSURL fileURLWithPath:@"/Users/username/Documents/"];