r/macosprogramming • u/B8edbreth • Jan 07 '24
Imagecapturekit
Is there an easier way to access scanners than imagecapturekit on macOS ? I cannot suss it out and the only objective-c example is 12 years old.
2
Upvotes
1
u/david_phillip_oster Jan 07 '24 edited Jan 07 '24
Do you mean: https://developer.apple.com/documentation/imagecapturecore ?
You create a browser and get an
ICDevicethat is a scanner. You set the delegate on it, and data comes back through calls by it on your delegate. YourequestOpenSession()thenrequestOverviewScan()thenrequestScan()The scanner calls your delegate withscannerDevice(_ scanner: ICScannerDevice, didScanTo url: URL)Here: I told you was easy. I wrote a working example for you: https://github.com/DavidPhillipOster/imageKitScanner
1
u/SurfRider_ Jan 17 '24
Hi David,
I did find your example online. You did it a little differently than I did, however I still have an odd issue that doesn't work with your version either. I'm wondering if anyone has a solution?
I want to use only the "Advanced" ScannerView mode AND I want to NOT show the "scan location" (thru the .xib) and set the download path programmatically with the [self.scannerView setDownloadsDirectory: [NSURL fileURLWithPath:path]]. If I look at the PrivateData just after setting, the download directory path is correct. However when I hit the Scan button, it says it cannot write to the folder and has changed the path to "/System/Applications/Photos.app".
Does anyone have any idea why this setting is not sticking? Same goes for trying to set the "Name" (e.g. [self.scannerView setDocumentName: @"Imagename"];). Thanks.