0

I am trying to initialize a ZXingWidgetController that can work for both 2D (QRCode, DataMatrix) and 1D Barcodes (UPC, EAN) My question is if this is possible or not.

This is the code I use

ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO];

QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init];
DataMatrixReader* dmReader = [[DataMatrixReader alloc] init];

MultiFormatUPCEANReader* upceanReader = [[MultiFormatUPCEANReader alloc] init];
MultiFormatOneDReader* oneDReader = [[MultiFormatOneDReader alloc] init];

NSSet *readers = [[NSSet alloc ] initWithObjects:qrcodeReader,dmReader,upceanReader,oneDReader, nil];

[qrcodeReader release];
[dmReader release];
[upceanReader release];
[oneDReader release];

widController.readers = readers;
[readers release];

If I put OneDMode:YES in initialization, then the app crashes with the following error

-[Not A Type _cfTypeID]: message sent to deallocated instance 0xded0270

But if I put OneDMode:NO in initialization, the app doesn't crash but it also doesn't work for barcodes, and works only with QRCodes & 2D datamatrix codes.

Can you tell me if this is possible or not and if it is, how to do it?

Any help is appreciated in advance.

BBog
  • 3,630
  • 5
  • 33
  • 64
Tarun
  • 152
  • 7

2 Answers2

0

As far as I know ZXing needs to be told whether it's looking for a 1D or 2D code which is why the OneDMode variable exists.

Aside from that though, it looks like the real problem you have is in memory management. Anytime you see that a message was sent to a deallocated instance that means you released something too early. I highly suggest using ARC instead of manual memory management.

Your particular error is typically something people see after converting to ARC so I'm not sure what state you are actually in. However, you may want to take a look at this other question and see if it helps you track down what your real issue is.

-[Not A Type retain]: message sent to deallocated instance

Community
  • 1
  • 1
SteveB
  • 652
  • 3
  • 12
0

You should use the trunk code in svn. There have been some 1D changes since the 2.0 release.

But see also the question "Why don't 1D codes work on iOS devices?" in the ZXing FAQ.

smparkes
  • 13,807
  • 4
  • 36
  • 61