<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/XPCArray/withUnsafeUnderlyingArray(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "s:3XPC8XPCArrayV25withUnsafeUnderlyingArrayyxxSo13OS_xpc_object_pKXEKlF"
  },
  "title" : "withUnsafeUnderlyingArray(_:)"
}
-->

# withUnsafeUnderlyingArray(_:)

Calls a closure with an unsafe reference to the array.

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

## Parameters

`closure`

A closure that takes an [`xpc_object_t`](/documentation/XPC/xpc_object_t) parameter. If `closure` has a return value, that value is also used as the return value for the withUnsafeUnderlyingArray(body:) function.

## Return Value

The return value, if any, of the closure.

---

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)