EnumURLRepresentation
The type that provides the URL for an app enum.
Declaration
struct EnumURLRepresentation<Enum> where Enum : AppEnumOverview
If you adopt the URLRepresentableEnum protocol in an app enum, use this type to build the URL for your type. Construct the type as a Swift string that contains characters suitable for use in a URL. To adjust the URL dynamically for your content, include a reference to your app enum value as part of the content. The following example shows an app enum type that includes the enum’s current value in the final URL:
enum Destination: String, AppEnum, URLRepresentableEnum {
case root
case locationServices
static var urlRepresentation = URLRepresentation("https://example.com/root=\(.rawValue)")
}If you need to differentiate URLs by more than the enum’s current value, provide an array of values for your representation instead. The following example shows the same enum from the previous example, but with distinct strings for each case.
enum Destination: String, AppEnum, URLRepresentableEnum {
case root
case locationServices
static var urlRepresentation = URLRepresentation([
.root: "https://example.com/link1=\(.root)",
.locationServices: "https://example.com/link2=\(.locationServices)"
])
}Make sure you define your app enum type using a URL-friendly value. The system automatically converts values of type String, Int, and URL to values suitable for inclusion in a URL.