AilaScanObject
Base object representing a scanned barcode.
Declaration
- Objective-C
- Swift
@interface AilaScanObject : NSObject
@property (nonatomic) AilaCodeType type;
@property (nonatomic) NSString *data;
- (NSString *)typeDescription;
@end
class AilaScanObject : NSObject {
var type: AilaCodeType
var data: String
func typeDescription() -> String
}
Description
This object is returned as part of the scanCallback upon a successful scan, and contains the type and data of the scan.
Properties
type
An enum representing the barcode symbology.
Type: AilaCodeType
Example values: AilaCodeTypeQR, AilaCodeType128, AilaCodeTypeUPC, etc.
data
The data contained inside the barcode.
Type: NSString / String
For a UPC-A code "123456789999", this property would contain the string "123456789999".
Methods
typeDescription
Returns the descriptive text for the barcode symbology.
Returns: NSString / String
For example, for AilaCodeTypeQR, this returns "QR".
Usage Example
- Objective-C
- Swift
config.scanCallback = ^(NSArray<AilaScanObject *> *results) {
for (AilaScanObject *scan in results) {
// Get type enum
AilaCodeType type = scan.type;
// Get human-readable type
NSString *typeStr = [scan typeDescription];
// Get barcode data
NSString *data = scan.data;
NSLog(@"Scanned %@ barcode: %@", typeStr, data);
// Check for specific type
if (type == AilaCodeTypeQR) {
NSLog(@"This is a QR code");
}
}
};
config.scanCallback = { results in
for scan in results {
// Get type enum
let type = scan.type
// Get human-readable type
let typeStr = scan.typeDescription()
// Get barcode data
let data = scan.data
print("Scanned \(typeStr) barcode: \(data)")
// Check for specific type
if type == .QR {
print("This is a QR code")
}
}
}
Subclasses
- AilaMRZScanObject - For MRZ scans
- AilaDLScanObject - For driver's license scans
See Also
- AilaCodeType - Code type enum values
- AilaConfiguration.scanCallback - Set scan callback