ImageCaptureCore功能:尽管设置了委托,但没有获得回调

时间:2016-02-16 14:01:09

标签: objective-c macos cocoa delegates scanning

我正在使用Apple的ImageCaptureCore框架以无头方式执行扫描操作。该框架提供了执行扫描的所有功能,而不涉及Apple之间的ICA对话。

现在,我所做的是写了一个符合ICDeviceBrowserICScannerDevice协议的课程。与此同时,我也设置了他们的代表。只要系统检测到ICA设备,就会触发以下功能:

/* 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;
}

从代码中可以看出,我已为ICScannerDeviceICDevice设置了代理。现在,我调用扫描过程:

[mScannerDevice requestScan];

理想情况下,这应该开始扫描过程,我应该期望对代理的其中一个方法进行回调,例如:

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

或:

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

或者至少在已经实施的代表的各种其他方法之一中。但是,我没有得到任何回调,即使在didEncounterError方法中也没有。

这种行为可能是什么原因?

0 个答案:

没有答案