<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGDataConsumer/init(data:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core Graphics",
      "CoreGraphics"
    ],
    "preciseIdentifier" : "c:@F@CGDataConsumerCreateWithCFData"
  },
  "title" : "init(data:)"
}
-->

# init(data:)

Creates a data consumer that writes to a CFData object.

```
init?(data: CFMutableData)
```

## Parameters

`data`

The CFData object to write to.

## Return Value

A new data consumer object. In Objective-C, you’re responsible for releasing this object using [`CGDataConsumerRelease`](/documentation/CoreGraphics/CGDataConsumerRelease).

## Discussion

You can use this function when you need to represent Core Graphics data as a <doc://com.apple.documentation/documentation/CoreFoundation/CFData> type. For example, you might create a <doc://com.apple.documentation/documentation/CoreFoundation/CFData> object that you then copy to the pasteboard.

---

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)