<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/xpc_copy(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "c:@F@xpc_copy"
  },
  "title" : "xpc_copy(_:)"
}
-->

# xpc_copy(_:)

Creates a copy of the object.

```
func xpc_copy(_ object: xpc_object_t) -> xpc_object_t?
```

## Parameters

`object`

The object to copy.

## Return Value

The new object. `NULL` if the object type does not support copying or if sufficient memory for the copy could not be allocated. Service objects do not support copying.

## Discussion

When called on an array or dictionary, [`xpc_copy(_:)`](/documentation/XPC/xpc_copy(_:)) will perform a deep copy.

The object returned is not necessarily guaranteed to be a new object, and whether it is will depend on the implementation of the object being copied.

---

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)