123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- //
- // KMBatchOperation.swift
- // PDF Reader Pro
- //
- // Created by kdanmobile on 2023/10/31.
- //
- import Foundation
- @objc(KMBatchOperateProtocol)
- protocol KMBatchOperateProtocol: AnyObject {
- @objc optional func fileBeginOperate(_ file: KMBatchOperateFile, info: KMBatchBaseParameter)
- @objc optional func fileOperating(_ file: KMBatchOperateFile, progress: CGFloat, info: KMBatchBaseParameter)
- @objc optional func fileOperateSuccessed(_ file: KMBatchOperateFile, info: KMBatchBaseParameter)
- @objc optional func fileOperateFailed(_ file: KMBatchOperateFile, error: NSError, info: KMBatchBaseParameter)
- @objc optional func fileOperateCanceled(_ file: KMBatchOperateFile, info: KMBatchBaseParameter)
- }
- class KMBatchOperation: Operation{
- var hasCanceled: Bool = false
- var hasFinished: Bool = false
- var hasExcuting: Bool = false
- weak var operateFile: KMBatchOperateFile?
- weak var delegate: KMBatchOperateProtocol?
-
- var viewController: NSViewController?
-
- init(file: KMBatchOperateFile) {
- super.init()
- self.operateFile = file
- }
- override var isCancelled: Bool{
- return self.hasCanceled
- }
- override var isFinished: Bool{
- return self.hasFinished
- }
- override var isExecuting: Bool{
- return self.hasExcuting
- }
- func errorWithMsg(_ errorMsg: String) -> NSError {
- var errorDict = NSMutableDictionary()
- errorDict[NSLocalizedDescriptionKey] = errorMsg
- let error = NSError(domain: "PDFReaderBatchErrorDomain", code: -1, userInfo: (errorDict as! [String : Any]))
- return error
- }
-
- }
|