ImageCaptureCore functionality: not getting callba

2019-07-12 19:41发布

I am using Apple's ImageCaptureCore framework to perform scanning operations in a headless fashion. The framework provides all the capabilities to perform scanning without involving the Apple's ICA dialog in between.

Now, what I have done is written a class that adheres to protocols of ICDeviceBrowser and ICScannerDevice. And alongwith, I have also set their delegates. The following function gets hit whenever an ICA device is detected by the system:

/* This message is sent to the delegate when a device has been added. This code adds the device to the cameras array. */
- (void)deviceBrowser:(ICDeviceBrowser*)browser didAddDevice:(ICDevice*)addedDevice moreComing:(BOOL)moreComing {
  NSLog( @"deviceBrowser:didAddDevice:moreComing: \n%@\n", addedDevice );

  if ( addedDevice.type & ICDeviceTypeScanner ) {
    addedDevice.delegate = self;

    mScannerDevice = (ICScannerDevice*)addedDevice;
    mScannerDevice.delegate = self;

    NSString * str = [addedDevice name];

    char *cpy = (char *)malloc([str length]+1);
    strlcpy(cpy, [str UTF8String], [str length] + 1);

    mICAScanners.push_back(cpy);
  }
  mScannersCollected = true;
}

As can be seen from the code, I have set the delegates for ICScannerDevice and ICDevice. Now, I invoke scanning process:

[mScannerDevice requestScan];

Ideally, this should start the scanning process and I should expect a callback to one of the methods of the delegates been implemented, for instance:

- (void)device:(ICDevice *)device didEncounterError:(NSError *)error {
  NSLog( @"device:didEncounterError:error: \n%@\n", error );
}

or:

 - (void)scannerDeviceView: (IKScannerDeviceView *)scanner didScanToURL: (NSURL *)url fileData: (NSData *)data error: (NSError *)error {
 }

Or at least in one of the various other methods of the delegates that have been implemented. But, I am not getting any callbacks, not even in the didEncounterError method.

What can be the reason for such a behavior?

0条回答
登录 后发表回答