iOS Developer Library

Developer

AVFoundation Framework Reference AVMetadataObject Class Reference

Options
Deployment Target:

On This Page
Language:

AVMetadataObject

Conforms To


Import Statement


Swift

import AVFoundation

Objective-C

@import AVFoundation;

Availability


Available in iOS 6.0 and later

The AVMetadataObject class is an abstract class that defines the basic properties associated with a piece of metadata. These attributes reflect information either about the metadata itself or the media from which the metadata originated. Subclasses are responsible for providing appropriate values for each of the relevant properties.

You should not subclass AVMetadataObject directly. Instead, you use one of the defined subclasses provided by the AV Foundation framework. Similarly, you do not create instances of this class yourself but use an AVCaptureMetadataOutput object to retrieve them from the captured data.

  • type type Property

    The type of the metadata. (read-only)

    Declaration

    Swift

    var type: String! { get }

    Objective-C

    @property(readonly) NSString *type

    Discussion

    You use this string to distinguish between different types of metadata. The possible values for this property are defined by subclasses, which can define constants for the type of metadata they represent.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later

  • time time Property

    The media time value associated with the metadata object. (read-only)

    Declaration

    Swift

    var time: CMTime { get }

    Objective-C

    @property(readonly) CMTime time

    Discussion

    For captured media, this property represents the time when the metadata was captured. For metadata originating from a sample buffer (CMSampleBufferRef), the time is the sample buffer’s presentation time. If there is no valid time value associated with the metadata, this property should contain kCMTimeInvalid.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later

  • duration duration Property

    The duration of the media associated with this metadata object. (read-only)

    Declaration

    Swift

    var duration: CMTime { get }

    Objective-C

    @property(readonly) CMTime duration

    Discussion

    For metadata originating from a sample buffer (CMSampleBufferRef), the duration reflects the duration of the sample buffer. If there is no valid duration value associated with the metadata, this property should contain kCMTimeInvalid.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later

  • bounds bounds Property

    The bounding rectangle associated with the metadata. (read-only)

    Declaration

    Swift

    var bounds: CGRect { get }

    Objective-C

    @property(readonly) CGRect bounds

    Discussion

    The bounding rectangle is specified relative to the picture or video of the corresponding media. The rectangle’s origin is always specified in the top-left corner, and the x and y axis extend down and to the right.

    If the metadata has no bounding rectangle, the value of this property should be CGRectZero.

    For video content, the bounding rectangle may be expressed using scalar values in the range 0.0 to 1.0. Scalar values remain meaningful even when the original video has been scaled down.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later