---
title: "withUnsafeUnderlyingDictionary(_:)"
framework: xpc
role: symbol
role_heading: Instance Method
path: "xpc/xpcdictionary/withunsafeunderlyingdictionary(_:)"
---

# withUnsafeUnderlyingDictionary(_:)

Calls a closure with an unsafe reference to the dictionary.

## Declaration

```swift
func withUnsafeUnderlyingDictionary<ReturnType>(_ closure: (xpc_object_t) throws -> ReturnType) rethrows -> ReturnType
```

## Parameters

- `closure`: A closure that takes an doc://com.apple.xpc/documentation/XPC/xpc_object_t parameter. If closure has a return value, that value is also used as the return value for the withUnsafeUnderlyingDictionary(body:) function.

## Return Value

Return Value The return value, if any, of the closure.

## Discussion

Discussion warning: It’s possible for closure to perform operations on the dictionary that cause the receiving dictionary to no longer wrap the underlying dictionary.

## See Also

### Accessing keys and values

- [keys](xpc/xpcdictionary/keys.md)
- [values](xpc/xpcdictionary/values.md)
- [subscript(_:)](xpc/xpcdictionary/subscript(_:)-4hbmg.md)
- [subscript(_:)](xpc/xpcdictionary/subscript(_:)-80fs2.md)
- [subscript(_:)](xpc/xpcdictionary/subscript(_:)-gas6.md)
- [subscript(_:)](xpc/xpcdictionary/subscript(_:)-4j21u.md)
- [subscript(_:)](xpc/xpcdictionary/subscript(_:)-8gyze.md)
- [subscript(_:)](xpc/xpcdictionary/subscript(_:)-4vrsa.md)
- [subscript(_:)](xpc/xpcdictionary/subscript(_:)-3i01t.md)
- [subscript(_:as:)](xpc/xpcdictionary/subscript(_:as:)-1mm7n.md)
- [subscript(_:as:)](xpc/xpcdictionary/subscript(_:as:)-4zxc8.md)
- [subscript(_:as:)](xpc/xpcdictionary/subscript(_:as:)-18db5.md)
- [subscript(_:as:)](xpc/xpcdictionary/subscript(_:as:)-5y39v.md)
- [subscript(_:as:)](xpc/xpcdictionary/subscript(_:as:)-qjxa.md)
- [subscript(_:as:)](xpc/xpcdictionary/subscript(_:as:)-3mzgc.md)
