更新时间:2023-02-23 10:58:19
使用-[NSURL path]
方法:
NSLog(@"%@", myUrl.path);
从文档中:
URL的路径,未使用
stringByReplacingPercentEscapesUsingEncoding:
方法进行转义.如果接收方不符合RFC 1808,则返回nil
.
The path of the URL, unescaped with the
stringByReplacingPercentEscapesUsingEncoding:
method. If the receiver does not conform to RFC 1808, returnsnil
.
如果此URL对象包含文件URL(由isFileURL
确定),则此方法的返回值适合于输入到NSFileManager或NSPathUtilities的方法中.如果路径中带有斜线,则将其删除.
If this URL object contains a file URL (as determined with isFileURL
), the return value of this method is suitable for input into methods of NSFileManager or NSPathUtilities. If the path has a trailing slash it is stripped.
根据RFC 3986,授权(主机名和端口)部分之后的斜杠被视为路径的一部分.
Per RFC 3986, the leading slash after the authority (host name and port) portion is treated as part of the path.
请注意,您可以使用+[NSURL fileURLWithPath:]
创建这样的URL.
Note that you can create such a URL with +[NSURL fileURLWithPath:]
.