Getting there. New issue while scanning QR codes. When a code is detected I need to convert an NSObject to what it actually is, an AVMetadataMachineReadableCodeObject. In the debugger I can see this as the description.
How can I convert/cast/extract the AVMetadataMachineReadableCodeObject or it’s superclass AVMetadataObject from the metadataObject ?
Many thanks in advance.
(BTW Multi-OS Engine works great!)
public class ScanController extends UIViewController implements AVCaptureMetadataOutputObjectsDelegate
{
@Override
public void captureOutputDidOutputMetadataObjectsFromConnection( AVCaptureOutput captureOutput, NSArray<?> metadataObjects, AVCaptureConnection connection )
{
for( Object metadataObject : metadataObjects )
{
try
{
boolean isInstance = metadataObject instanceof AVMetadataMachineReadableCodeObject; // always false
AVMetadataObject data = ( AVMetadataObject ) metadataObject; // << FAILS
if( data.type().equals( AVFoundation.AVMetadataObjectTypeQRCode() ) )
{
AVMetadataMachineReadableCodeObject qrCode;
qrCode = ( AVMetadataMachineReadableCodeObject ) previewLayer.transformedMetadataObjectForMetadataObject( data );
foundQRCode( qrCode.stringValue() );
}
}
catch( Exception e )
{
e.printStackTrace();
}
}
}
}