如何用特殊字符删除NSURL的最后路径
所以我有点困惑。我有这样的nsurl,
https://something/something/test#4.html
我想删除这最后的最后路径。我尝试使用urlbyDeletingLastPathComponent方法,但随后导致了这一点。
https://something/something/#4.html
我希望最终结果是以下内容。
https://something/something
So I'm a little confused. I have an NSURL like this
https://something/something/test#4.html
I want to remove the last path of this. I tried using URLByDeletingLastPathComponent method but then it results in this.
https://something/something/#4.html
I want the end result to be the following.
https://something/something
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
删除片段的一种明智的方法是
urlComponents
A smart way to remove the fragment is
URLComponents
首先,您必须删除片段。然后使用
deletinglastpathcomponent()
的最后一个路径。First you have to remove the fragment. Then the last path using
deletingLastPathComponent()
.