<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppIntents",
  "identifier" : "/documentation/AppIntents/EnumURLRepresentation",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "App Intents"
    ],
    "preciseIdentifier" : "s:10AppIntents21EnumURLRepresentationV"
  },
  "title" : "EnumURLRepresentation"
}
-->

# EnumURLRepresentation

The type that provides the URL for an app enum.

```
struct EnumURLRepresentation<Enum> where Enum : AppEnum
```

## Overview

If you adopt the [`URLRepresentableEnum`](/documentation/AppIntents/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:

```swift
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.

```swift
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
<doc://com.apple.documentation/documentation/Swift/String>, <doc://com.apple.documentation/documentation/Swift/Int>,
and <doc://com.apple.documentation/documentation/Foundation/URL> to values suitable for inclusion in a URL.

## Topics

### Structures

[`struct EnumSingleURLRepresentation`](/documentation/AppIntents/EnumURLRepresentation/EnumSingleURLRepresentation)

### Initializers

[`init([Enum : EnumURLRepresentation<Enum>.EnumSingleURLRepresentation])`](/documentation/AppIntents/EnumURLRepresentation/init(_:)-1odm)

Creates a URL representation for an app enum using the provided dictionary.

[`init(String)`](/documentation/AppIntents/EnumURLRepresentation/init(_:)-6p999)

Creates a URL representation for an app enum using the provided Swift string.

## Relationships

### Conforms To

[`ExpressibleByStringLiteral`](/documentation/Swift/ExpressibleByStringLiteral)

[`ExpressibleByUnicodeScalarLiteral`](/documentation/Swift/ExpressibleByUnicodeScalarLiteral)

[`ExpressibleByStringInterpolation`](/documentation/Swift/ExpressibleByStringInterpolation)

[`ExpressibleByExtendedGraphemeClusterLiteral`](/documentation/Swift/ExpressibleByExtendedGraphemeClusterLiteral)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)