Skip to content

Commit

Permalink
Implement secure coding
Browse files Browse the repository at this point in the history
  • Loading branch information
vincode-io committed Sep 3, 2024
1 parent caf2b6e commit a08bec5
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import UIKit

public class ImageTextAttachment: NSTextAttachment {

public override class var supportsSecureCoding: Bool { return true }

public var imageUUID: String? = nil

public override init(data contentData: Data?, ofType uti: String?) {
Expand All @@ -20,7 +22,13 @@ public class ImageTextAttachment: NSTextAttachment {
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
super.init(coder: coder)
imageUUID = coder.decodeObject(forKey: "imageUUID") as? String
}

public override func encode(with coder: NSCoder) {
coder.encode(imageUUID, forKey: "imageUUID")
super.encode(with: coder)
}

public override func attachmentBounds(for textContainer: NSTextContainer?, proposedLineFragment lineFrag: CGRect, glyphPosition position: CGPoint, characterIndex charIndex: Int) -> CGRect {
Expand Down

0 comments on commit a08bec5

Please sign in to comment.