Structure
URI
struct URI
Overview
Warning
This is NOT the same as Foundation’s URL type!
Can be used to both parse strings containing well-formed URIs and to generate such strings from a set of individual URI components.
Use of this type is (gently, for now) discouraged. Consider using Foundation’s URL and/or URLComponents types instead. See below for details.
URI is for URLs, not URIs
Thanks to both backwards compatibility requirements and name collision concerns, this type, despite its name, does not actually represent a generic Uniform Resource Identifier as defined by RFC 3986. In particular, the underlying implementation is currently based on Foundation’s URLComponents type, whose semantics are inconsistent between different methods; in addition, its behavior has differed drastically between the macOS and Linux implementations for most of its existence, and continues to do so in Swift 5.9. This is not expected to be remedied until the swift-foundation package reaches a 1.0 release, which as of this writing will not for quite some time yet). In short, instances of URI may not always behave as expected according to either the spec or what Foundation does.
Topics
Structures
URI.SchemeA URI scheme, as defined by RFC 3986 § 3.1 and [RFC 7595].
Initializers
init(from:)Creates a new instance by decoding from the given decoder.init(scheme:host:port:path:query:fragment:)init(scheme:userinfo:host:port:path:query:fragment:)init(string:)Create aURIby parsing a given string according to the semantics of RFC 3986.init(stringLiteral:)Creates an instance initialized to the given string value.
Instance Properties
descriptionA textual representation of this instance.fragmenthostpathportqueryschemestringuserinfo
Instance Methods
encode(to:)Encodes this value into the given encoder.
Relationships
Conforms To
Swift.CustomStringConvertibleSwift.DecodableSwift.EncodableSwift.EquatableSwift.ExpressibleByExtendedGraphemeClusterLiteralSwift.ExpressibleByStringInterpolationSwift.ExpressibleByStringLiteralSwift.ExpressibleByUnicodeScalarLiteralSwift.HashableSwift.SendableSwift.SendableMetatype