Search code examples
iphoneiosqr-codezbar

How to get the type of bar code from zbar?


In my application, Zbar is decoding perfectly. But the problem is Zbar can decode both QR code and bar code. So after decoding, how do I get the type of Encoding Style?


Solution

  • There are return codes for type in ZBarSymbol. You will be looking for ZBAR_QRCODE for QR codes

    ZBarSymbol documentation

    Something like this should help you to get the symbol out:

    - (void) readerView: (ZBarReaderView*) view didReadSymbols: (ZBarSymbolSet*) syms  fromImage: (UIImage*) img 
    {
        //do something useful with results and display resultText in resultViewController
        for(ZBarSymbol *sym in syms) 
        {
            imageResult3.image = img; 
            resultText.text = sym.typeName;
            resultText.text =  [ resultText.text stringByAppendingString:@" - " ];
            resultText.text =  [ resultText.text stringByAppendingString:sym.data ]; 
    
        }
    }