URLComponents.init(url:resolvingAgainstBaseURL:)
的文档说明如下:返回初始化的URL组件对象,如果无法解析URL则返回nil。
需要知道的是:
Swift URL / NSURL用于基于RFC 1808、RFC 1738和RFC 2732的URL:https://developer.apple.com/documentation/foundation/nsurl Swift URLComponents / NSURLComponents用于基于RFC 3986的URL:https://developer.apple.com/documentation/foundation/nsurlcomponents 我认为当URL符合RFC 1808/1738/2732但不符合RFC 3986时,
URLComponents
的初始化将失败。这种类型的URL是什么?有示例吗?到目前为止,唯一的提示可能与不同的保留字符有关。