Note
This API is still in beta and may change in future versions of Scandit Data Capture SDK.
Scan Item Definition
Defined in framework ScanditBarcodeCapture
- ScanItemDefinition
class ScanItemDefinition : NSObject
Added in version 8.0.0
A definition for a target scan item in the item-based scanning APIs that represents a collection of related scan components. A scan item definition can contain multiple barcode and text components that are logically grouped together.
You can create scan item definitions in two ways:
Builder Pattern - Use Swift’s result builder pattern for fluent configuration
Manual Construction - Create with explicit component lists using the initializer
Here is an example of how to use the builder pattern to create a scan item definition:
let barcodeIdentifier = BarcodeIdentifier() let expiryDateIdentifier = TextIdentifier() let definition = ScanItemDefinition { BarcodeDefinition(barcodeIdentifier, symbologies: [.code128]) .optional(false) .valueRegexes(["123.*", "789.*"]) .anchorRegexes(["Identifier"]) TextDefinition(expiryDateIdentifier) .optional(true) .semantics(.expiryDate) }
- init
init(_ identifier: ScanItemIdentifier, components: Array<any ScanComponentDefinition>)
Added in version 8.0.0
A constructor that requires an identifier and a list of ScannedComponent objects that make up the item.
- init
convenience init(_ components: Array<any ScanComponentDefinition>)
Added in version 8.0.0
A constructor that requires a list of ScannedComponent objects that make up the item. It uses default identifier.
- identifier
var identifier: ScanItemIdentifier { get }
Added in version 8.0.0
The unique identifier for this scanned item.
- onScan
var onScan: ((_ item: ScannedItem) ->
Void)? { get, set }Added in version 8.0.0
A callback that gets called every time a new scan item is detected.
- components
var components: Array<any ScanComponentDefinition> { get }
Added in version 8.0.0
An array of all scan components that make up this item. Components can be either ScannedBarcode or ScannedText objects.