<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/XPCDictionary/init(dictionaryLiteral:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "s:3XPC13XPCDictionaryV17dictionaryLiteralACSS_AA15XPCLiteralValueVtd_tcfc"
  },
  "title" : "init(dictionaryLiteral:)"
}
-->

# init(dictionaryLiteral:)

Creates an `XPCDictionary` initialized with the given key-value pairs.

```
init(dictionaryLiteral elements: (String, XPCLiteralValue)...)
```

## Parameters

`elements`

The key-value pairs that will make up the new dictionary.
Values can be strings, integers, booleans, floating-point numbers,
or other XPC-compatible types.

## Discussion

Example usage:

```swift
let dict: XPCDictionary = [
    "name": "John",
    "age": 30,
    "isActive": true,
    "score": 95.5
]
```

For more complex types, you can explicitly create XPCLiteralValue:

```swift
let dict: XPCDictionary = [
    "nested": XPCLiteralValue(anotherDict),
    "endpoint": XPCLiteralValue(someEndpoint)
]
```

---

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)