123456789101112131415161718192021222324252627282930313233343536373839 |
- //
- // KMPDFConvertManager.swift
- // PDF Master
- //
- // Created by tangchao on 2022/12/7.
- //
- import Cocoa
- class KMPDFConvertManager: NSObject {
-
- static let defaultManager = KMPDFConvertManager()
-
- var operationQueue: OperationQueue = OperationQueue()
-
- override init() {
- super.init()
-
- operationQueue.maxConcurrentOperationCount = 1
- }
-
- func convert(convert: KMPDFConvert, completion: @escaping (_ finished: Bool, _ error: Error?) -> ()) {
- convert.callback = completion
-
- operationQueue.addOperation(convert)
- }
-
- func convert(convert: KMPDFConvert, progress:@escaping (Int)->Void, completion: @escaping (_ finished: Bool, _ error: Error?) -> ()) {
- convert.callback = completion
- convert.progress = progress
-
- operationQueue.addOperation(convert)
- }
-
- func cancel(convert: KMPDFConvert) {
- convert.cancel()
- self.operationQueue.cancelAllOperations()
- }
- }
|