Page Summary
-
MLKBarcodeScanner is an object used for detecting barcodes within images.
-
It offers both synchronous and asynchronous processing methods.
-
Provides options for custom configuration or default settings.
-
Results are returned as an array of MLKBarcode objects.
-
Avoid calling the synchronous method on the main thread to prevent UI blockage.
MLKBarcodeScanner
@interface MLKBarcodeScanner : NSObjectA barcode scanner that scans barcodes in an image.
-
Returns a barcode scanner with the given options.
Declaration
Objective-C
+ (nonnull instancetype)barcodeScannerWithOptions: (nonnull MLKBarcodeScannerOptions *)options;Parameters
optionsOptions containing barcode scanner configuration.
Return Value
A barcode scanner configured with the given options.
-
Returns a barcode scanner with the default options.
Declaration
Objective-C
+ (nonnull instancetype)barcodeScanner;Return Value
A barcode scanner configured with the default options.
-
Unavailable. Use the class methods.
Declaration
Objective-C
- (nonnull instancetype)init; -
Processes the given image for barcode scanning.
Declaration
Objective-C
- (void)processImage:(nonnull id<MLKCompatibleImage>)image completion:(nonnull MLKBarcodeScanningCallback)completion;Parameters
imageThe image to process.
completionHandler to call back on the main queue with barcodes scanned or error.
-
Returns barcode results in the given image or
nilif there was an error. The barcode scanning is performed synchronously on the calling thread.It is advised to call this method off the main thread to avoid blocking the UI. As a result, an
NSExceptionis raised if this method is called on the main thread.Declaration
Objective-C
- (nullable NSArray<MLKBarcode *> *) resultsInImage:(nonnull id<MLKCompatibleImage>)image error:(NSError *_Nullable *_Nullable)error;Parameters
imageThe image to get results in.
errorAn optional error parameter populated when there is an error getting results.
Return Value
Array of barcode results in the given image or
nilif there was an error.