Question

I've never worked with non-ARC before, and I tried ZXingObjC sample project (QR Code Scanner), it's non-ARC project as well as the library. I started with deleting the autorealese, dealloc etc. But I've encounter 'retain' and I don't know yet how to handle it. I'll glad for a hand as it will benefit a lot of us.

Example of 'retain' statements:

if (zxd) {
    input =
      [ZXCaptureDeviceInput deviceInputWithDevice:zxd
                                       ZXAV(error:nil)];
    [input retain];
  }

Another One:

- (void)setCaptureDevice:(ZXCaptureDevice *)device {
  if (device == capture_device) {
    return;
  }

  if(capture_device) {
    ZXQT({
      if ([capture_device isOpen]) {
        [capture_device close];
      }});
    [capture_device release];
  }

  capture_device = [device retain];
}

EDIT: OK, I've been trying to make "EDIT --> Refactor --> Convert to Objective-C ARC", I get: enter image description here

Was it helpful?

Solution 2

OK, what I did is:

  1. Clean all non-ARC old code.
  2. "EDIT --> Refactor --> Convert to Objective-C ARC".
  3. Added missing AudioToolbox.Framework

Project now fully work with ARC. I'll upload later to github.

OTHER TIPS

Another way to use "ZXingOjbC" without convert it to arc projcet:

I use the library by turning off arc when compile it's source code, it works fine when combining both arc and non-arc code in the same project.

use following steps:

  1. put "ZXingObjC" source folder into your project
  2. go to project->Build Phases
  3. select all ZXingObjc files(you can select all at once by pressing shift) then press Enter.
  4. key in "-fno-objc-arc" tell compiler to compile these source code without arc.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top