1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- //
- // KMSignatureManager.swift
- // PDF Reader Pro
- //
- // Created by lizhe on 2023/10/9.
- //
- import Foundation
- @objcMembers class KMSignatureManager: NSObject {
- var signatureList: [KMSignature] = []
- var filePath: String = ""
-
- override init() {
- signatureList = []
-
- if let fileDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first {
- let fileName = "LyncPDFEditorSignatureList"
- let newFilePath = fileDirectory.appendingPathComponent(fileName)
- filePath = newFilePath.path
- }
- }
- @objc func loadAllSignatureList() {
- signatureList.removeAll()
-
- if FileManager.default.fileExists(atPath: filePath) {
- if let array = NSKeyedUnarchiver.unarchiveObject(withFile: filePath) as? [KMSignature] {
- for model in array {
- signatureList.append(model)
- }
- }
- }
- }
-
- func removeAllObject() {
- signatureList.removeAll()
- }
-
- func removeObject(index: Int) {
- signatureList.remove(at: index)
- }
- @objc func addSignature(_ signature: KMSignature) {
- signatureList.append(signature)
- }
- @objc func saveSingaturesToFile() {
- if filePath.isEmpty == false {
- NSKeyedArchiver.archiveRootObject(signatureList, toFile: filePath)
- }
-
- }
- }
|