<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 10.14.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateML",
  "identifier" : "/documentation/CreateML/MLDataValueConvertible",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Create ML"
    ],
    "preciseIdentifier" : "s:8CreateML22MLDataValueConvertibleP"
  },
  "title" : "MLDataValueConvertible"
}
-->

# MLDataValueConvertible

A type that can convert itself to and from a data value.

```
protocol MLDataValueConvertible
```

## Overview

You can use any type that conforms to the [`MLDataValueConvertible`](/documentation/CreateML/MLDataValueConvertible)
protocol in an [`MLDataValue`](/documentation/CreateML/MLDataValue) or an [`MLDataTable`](/documentation/CreateML/MLDataTable). For example, you can
create a data table by using its [`init(dictionary:)`](/documentation/CreateML/MLDataTable/init(dictionary:))
initializer with a
`[`<doc://com.apple.documentation/documentation/Swift/String>`: ``MLDataValueConvertible``]` dictionary.

## Topics

### Converting from a data value to a type’s instance

[`init()`](/documentation/CreateML/MLDataValueConvertible/init())

Creates a new default instance of the conforming type when a data value
is missing or invalid.

[`init(from:)`](/documentation/CreateML/MLDataValueConvertible/init(from:))

Creates an instance of the conforming type from a data value.

### Converting from a type’s instance to a data value

[`dataValue`](/documentation/CreateML/MLDataValueConvertible/dataValue)

The value of the conforming type’s instance wrapped in a data value.

[`dataValueType`](/documentation/CreateML/MLDataValueConvertible/dataValueType)

The underlying type the conforming type uses when it wraps itself in a
data value.



---

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)