---
title: "newTexture(data:options:completionHandler:)"
framework: metalkit
role: symbol
role_heading: Instance Method
path: "metalkit/mtktextureloader/newtexture(data:options:completionhandler:)"
---

# newTexture(data:options:completionHandler:)

Asynchronously creates a new Metal texture from an in-memory representation of the texture’s data.

## Declaration

```swift
func newTexture(data: Data, options: [MTKTextureLoader.Option : Any]? = nil, completionHandler: @escaping @Sendable ((any MTLTexture)?, (any Error)?) -> Void)
```

```swift
func newTexture(data: Data, options: [MTKTextureLoader.Option : Any]? = nil) async throws -> any MTLTexture
```

## Parameters

- `data`: The doc://com.apple.documentation/documentation/Foundation/NSData object containing image data.
- `options`: A dictionary describing any additional texture loading steps. See Texture Loading Options.
- `completionHandler`: A block called when the texture has been loaded and fully initialized.

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func newTexture(data: Data, options: [MTKTextureLoader.Option : Any]? = nil) async throws -> MTLTexture For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously.

## See Also

### Loading Textures from In-Memory Data Representations

- [newTexture(data:options:)](metalkit/mtktextureloader/newtexture(data:options:).md)
