AI-generated Key Takeaways
-
MLKBarcoderepresents a barcode detected within an image, providing access to its data and metadata. -
It offers properties to retrieve the barcode's format, raw and display values, bounding box, and corner points.
-
Depending on the barcode type, specific structured data like email, URL, Wi-Fi details, or contact information can be accessed through dedicated properties.
-
The
valueTypeproperty indicates the kind of data encoded in the barcode, whileframedefines its location within the image. -
Developers can use this class to extract and utilize information from barcodes scanned using ML Kit.
MLKBarcode
@interface MLKBarcode : NSObjectA barcode in an image.
-
The rectangle that holds the discovered barcode relative to the detected image in the view coordinate system.
Declaration
Objective-C
@property (nonatomic, readonly) CGRect frame; -
A barcode value as it was encoded in the barcode. Structured values are not parsed, for example: ‘MEBKM:TITLE:Google;URL:https://www.google.com;;’. Does not include the supplemental value.
It’s only available when the barcode is encoded in the UTF-8 format, and for non-UTF8 barcodes use
rawDatainstead.Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSString *rawValue; -
Raw data stored in barcode.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSData *rawData; -
A barcode value in a user-friendly format. May omit some of the information encoded in the barcode. For example, in the case above the display value might be ‘https://www.google.com’. If
valueType == .text, this field will be equal torawValue. This value may be multiline, for example, when line breaks are encoded into the original TEXT barcode value. May include the supplement value.Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSString *displayValue; -
A barcode format; for example, EAN_13. Note that if the format is not in the list,
.unknownwould be returned.Declaration
Objective-C
@property (nonatomic, readonly) MLKBarcodeFormat format; -
The four corner points of the barcode, in clockwise order starting with the top left relative to the detected image in the view coordinate system. These are
CGPointswrapped inNSValues. Due to the possible perspective distortions, this is not necessarily a rectangle.Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSArray<NSValue *> *cornerPoints; -
A type of the barcode value. For example, TEXT, PRODUCT, URL, etc. Note that if the type is not in the list,
.unknownwould be returned.Declaration
Objective-C
@property (nonatomic, readonly) MLKBarcodeValueType valueType; -
An email message from a
MAILTO:or similar QR Code type. This property is only set ifvalueTypeis.email.Declaration
Objective-C
@property (nonatomic, readonly, nullable) MLKBarcodeEmail *email; -
A phone number from a ‘TEL:’ or similar QR Code type. This property is only set if
valueTypeis.phone.Declaration
Objective-C
@property (nonatomic, readonly, nullable) MLKBarcodePhone *phone; -
An SMS message from an ‘SMS:’ or similar QR Code type. This property is only set if
valueTypeis.sms.Declaration
Objective-C
@property (nonatomic, readonly, nullable) MLKBarcodeSMS *sms; -
A URL and title from a ‘MEBKM:’ or similar QR Code type. This property is only set if
valueTypeis.url.Declaration
Objective-C
@property (nonatomic, readonly, nullable) MLKBarcodeURLBookmark *URL; -
Wi-Fi network parameters from a ‘WIFI:’ or similar QR Code type. This property is only set if
valueTypeis.wifi.Declaration
Objective-C
@property (nonatomic, readonly, nullable) MLKBarcodeWiFi *wifi; -
GPS coordinates from a
GEO:or similar QR Code type. This property is only set ifvalueTypeis.geo.Declaration
Objective-C
@property (nonatomic, readonly, nullable) MLKBarcodeGeoPoint *geoPoint; -
A person’s or organization’s business card. For example a VCARD. This property is only set if
valueTypeis.contactInfo.Declaration
Objective-C
@property (nonatomic, readonly, nullable) MLKBarcodeContactInfo *contactInfo; -
A calendar event extracted from a QR Code. This property is only set if
valueTypeis.calendarEvent.Declaration
Objective-C
@property (nonatomic, readonly, nullable) MLKBarcodeCalendarEvent *calendarEvent; -
A driver’s license or ID card. This property is only set if
valueTypeis.driverLicense.Declaration
Objective-C
@property (nonatomic, readonly, nullable) MLKBarcodeDriverLicense *driverLicense; -
Unavailable.
Declaration
Objective-C
- (nonnull instancetype)init;