---
title: "copyAsync(to:completionHandler:)"
framework: realitykit
role: symbol
role_heading: Instance Method
path: "realitykit/textureresource/copyasync(to:completionhandler:)"
---

# copyAsync(to:completionHandler:)

Asynchronously copies texture data to another texture.

## Declaration

```swift
@MainActor @preconcurrency func copyAsync(to texture: any MTLTexture, completionHandler: @escaping @MainActor ((any Error)?) -> Void)
```

## Parameters

- `texture`: The target texture for copying the data. It needs to have the same width and height as doc://com.apple.RealityKit/documentation/RealityKit/TextureResource, and doc://com.apple.documentation/documentation/Metal/MTLTextureUsage/shaderWrite usage.
- `completionHandler`: The system calls this closure after it finishes copying the data, with a nil error if it succeeds.

## Discussion

Discussion This function is asynchronous. It returns immediately and runs in the background, calling completionHandler when it finishes or errors. This method copies all available mipmap sizes to texture. It’s recommended that you provide a value for semantic when creating this resource. Specifying a semantic enables RealityKit to select an appropriate pixel format for the target texture.

## See Also

### Copying the texture

- [copy(to:)](realitykit/textureresource/copy(to:)-jfbi.md)
