// // LabelAttributeAttachment.swift // VDS // // Created by Matt Bruce on 8/9/22. // import Foundation import UIKit public protocol AttachmentLabelAttributeModel: LabelAttributeModel { func getAttachment() throws -> NSTextAttachment } extension AttachmentLabelAttributeModel { public func setAttribute(on attributedString: NSMutableAttributedString) { guard isValidRange(on: attributedString) else { return } do { let mutableString = NSMutableAttributedString() let attachment = try getAttachment() mutableString.append(NSAttributedString(attachment: attachment)) attributedString.insert(mutableString, at: location) } catch { //TODO: Error Handling } } }