1
1
1
} else {
print("Session closed successfully.")
}
}mport Foundation
func closePTPSession() {
guard let camera = cameraDevice else { return }
// Usage
let cameraController = CameraController()
class CameraController: NSObject, ICDeviceDelegate {
var cameraDevice: ICCameraDevice?
var sessionID: UInt32 = 1 // PTP 会话 ID,通常从 1 开始
override init() {
import ImageCaptureCore
func device(_ device: ICDevice, didCloseSessionWithError error: Error?) {
if let error = error {
print("Failed to close session: \(error.localizedDes
mport Foundation
func closePTPSession() {
guard let camera = cameraDevice else { return }
// Usage
let cameraController = CameraController()
class CameraController: NSObject, ICDeviceDelegate {
var cameraDevice: ICCameraDevice?
var sessionID: UInt32 = 1 // PTP 会话 ID,通常从 1 开始
override init() {
import ImageCaptureCore
func device(_ device: ICDevice, didCloseSessionWithError error: Error?) {
if let error = error {
print("Failed to close session: \(error.localizedDes
func openPTPSession() {
guard let camera = cameraDevice else { return }
func performCameraOperations() {
// Example operation: Get the list of files on the camera
guard let camera = cameraDevice else { return }
super.init()
let deviceBrowser = ICDeviceBrowser()
deviceBrowser.delegate = self
deviceBrowser.browsedDeviceTypeMask = ICDeviceTypeMask.camera.rawValue
deviceBrowser.start()
}
// MARK: - ICDeviceDelegate