iOS Developer Library

Developer

ApplicationServices Framework Reference CGDataConsumer Reference

Options
Deployment Target:

On This Page
Language:

CGDataConsumer Reference

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import CoreGraphics

Objective-C

@import CoreGraphics;

The CGDataConsumerRef opaque type abstracts the data-writing task and eliminates the need for applications to manage data through a raw memory buffer. You can use data consumer objects to write image or PDF data and all, except for CGDataConsumerCreateWithCFData, are available in OS X v10.0 or later.

If your application runs in OS X v10.4 or later, you should use CGImageDestination objects rather than data consumers. See CGImageDestination Reference.

Functions

  • Creates a data consumer that uses callback functions to write data.

    Declaration

    Swift

    func CGDataConsumerCreate(_ info: UnsafeMutablePointer<Void>, _ callbacks: UnsafePointer<CGDataConsumerCallbacks>) -> CGDataConsumer!

    Objective-C

    CGDataConsumerRef CGDataConsumerCreate ( void *info, const CGDataConsumerCallbacks *callbacks );

    Parameters

    info

    A pointer to data of any type or NULL. When Quartz calls the functions specified in the callbacks parameter, it passes this pointer as the info parameter.

    callbacks

    A pointer to a CGDataConsumerCallbacks structure that specifies the callback functions you implement to copy data sent to the consumer and to handle the consumer’s basic memory management. For a complete description, see CGDataConsumerCallbacks.

    Return Value

    A new data consumer object. You are responsible for releasing this object using CGDataConsumerRelease.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in iOS 2.0 and later.

  • Creates a data consumer that writes data to a location specified by a URL.

    Declaration

    Swift

    func CGDataConsumerCreateWithURL(_ url: CFURL!) -> CGDataConsumer!

    Objective-C

    CGDataConsumerRef CGDataConsumerCreateWithURL ( CFURLRef url );

    Parameters

    url

    A CFURL object that specifies the data destination.

    Return Value

    A new data consumer object. You are responsible for releasing this object using CGDataConsumerRelease.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in iOS 2.0 and later.

  • Creates a data consumer that writes to a CFData object.

    Declaration

    Swift

    func CGDataConsumerCreateWithCFData(_ data: CFMutableData!) -> CGDataConsumer!

    Objective-C

    CGDataConsumerRef CGDataConsumerCreateWithCFData ( CFMutableDataRef data );

    Parameters

    data

    The CFData object to write to.

    Return Value

    A new data consumer object. You are responsible for releasing this object using CGDataConsumerRelease.

    Discussion

    You can use this function when you need to represent Quartz data as a CFData type. For example, you might create a CFData object that you then copy to the pasteboard.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in iOS 2.0 and later.

  • Returns the Core Foundation type identifier for Quartz data consumers.

    Declaration

    Swift

    func CGDataConsumerGetTypeID() -> CFTypeID

    Objective-C

    CFTypeID CGDataConsumerGetTypeID ( void );

    Return Value

    The Core Foundation identifier for the opaque type CGDataConsumerRef.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in iOS 2.0 and later.

  • Decrements the retain count of a data consumer.

    Declaration

    Objective-C

    void CGDataConsumerRelease ( CGDataConsumerRef consumer );

    Parameters

    consumer

    The data consumer to release.

    Discussion

    This function is equivalent to CFRelease, except that it does not cause an error if the consumer parameter is NULL.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Availability

    Available in iOS 2.0 and later.

  • Increments the retain count of a data consumer.

    Declaration

    Objective-C

    CGDataConsumerRef CGDataConsumerRetain ( CGDataConsumerRef consumer );

    Parameters

    consumer

    The data consumer to retain.

    Return Value

    The same data consumer you passed in as the consumer parameter.

    Discussion

    This function is equivalent to CFRetain, except that it does not cause an error if the consumer parameter is NULL.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Availability

    Available in iOS 2.0 and later.

Callbacks

  • Copies data from a Quartz-supplied buffer into a data consumer.

    Declaration

    Swift

    typealias CGDataConsumerPutBytesCallback = CFunctionPointer<((UnsafeMutablePointer<Void>, UnsafePointer<Void>, Int) -> Int)>

    Objective-C

    size_t (*CGDataConsumerPutBytesCallback) ( void *info, const void *buffer, size_t count );

    Parameters

    info

    A generic pointer to private data shared among your callback functions. This is the pointer supplied to CGDataConsumerCreate.

    buffer

    The Quartz-supplied buffer from which you copy the specified number of bytes.

    count

    The number of bytes to copy.

    Return Value

    The number of bytes copied. If no more data can be written to the consumer, you should return 0.

    Discussion

    When Quartz is ready to send data to the consumer, your function is called. It should copy the specified number of bytes from buffer into some resource under your control—for example, a file.

    For information on how to associate your callback function with a data consumer, see CGDataConsumerCreate and CGDataConsumerCallbacks.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in iOS 2.0 and later.

  • Releases any private data or resources associated with the data consumer.

    Declaration

    Swift

    typealias CGDataConsumerReleaseInfoCallback = CFunctionPointer<((UnsafeMutablePointer<Void>) -> Void)>

    Objective-C

    void (*CGDataConsumerReleaseInfoCallback) ( void *info );

    Parameters

    info

    A generic pointer to private data shared among your callback functions. This is the same pointer you supplied to CGDataConsumerCreate.

    Discussion

    When Quartz frees a data consumer that has an associated release function, the release function is called.

    For information on how to associate your callback function with a data consumer, see CGDataConsumerCreate and CGDataConsumerCallbacks.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in iOS 2.0 and later.

Data Types