ios - 为什么 initWithScheme 初始化的 NSURL 中有尾部斜杠...?

标签 ios objective-c iphone xcode

当使用 NSURL 初始化器时

initWithScheme:(NSString *) host:(NSString *) path:(NSString *)

如果路径以斜杠结尾,iOS 出于某种原因会附加两个额外的尾部斜杠,除非它只是 @"/"

enter image description here

有谁知道这是为什么,如果有办法解决它除了用类似的东西手动组成 url

[NSURL URLWithString:[NSString stringWithFormat:@"%@://%@%@", scheme, host, path]];

更新:错误报告已发送给 Apple。

最佳答案

文件路径以“/”开头但不以“/”结尾。

发件人:Uniform resource locator :

语法是:

scheme://[user:password@]domain:port/path?query_string#fragment_id

目录路径有尾随“/”,但似乎 - initWithScheme:host:path: 不支持它们,可能只是 Apache 约定。

关于ios - 为什么 initWithScheme 初始化的 NSURL 中有尾部斜杠...?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30151857/

相关文章:

iphone - iOS API 检测无线网络

ios - 为什么调整应用程序的 postinst 脚本因为应用程序图标消失了?

javascript - iPhone AVPlayer 从 PhoneGap 中的远程 URL 进行流式传输

objective-c - 创建和隐藏 UILabel

iphone - 移动网络上的语音录制/播放(Android、iOS、BB)

android - 编译/部署期间 iOS 模拟器错误 "Failed to launch the simulator: Array index is out of range"(MT1008)

iphone - 顶部带有圆角的 UIButton

ios - Swift NSTimer 无法识别的选择器发送到实例 timerFireMethod

ios - 在 iOS 中将 3 条线动画化为 uibutton 的箭头

iphone - 记录到 iPhone 上的文件