ImageCaptureCore functionality: not getting callbacks despite the delegates being set

a 夏天 提交于 2019-12-10 22:30:50

问题


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?

来源:https://stackoverflow.com/questions/35434605/imagecapturecore-functionality-not-getting-callbacks-despite-the-delegates-bein

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!