Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kiarashvosough1999/13efc9229b3765ae5a997f0bc91a4e28 to your computer and use it in GitHub Desktop.
Save kiarashvosough1999/13efc9229b3765ae5a997f0bc91a4e28 to your computer and use it in GitHub Desktop.
import UIKit
public struct CocoStringAttributeHolder {
internal let key: NSAttributedString.Key
internal let value: Any
internal let range: Range<String.Index>?
fileprivate init(key: NSAttributedString.Key, value: Any, range: Range<String.Index>?) {
self.key = key
self.value = value
self.range = range
}
}
extension CocoStringAttributeHolder {
public static func attribute(key: NSAttributedString.Key, value: Any) -> Self {
.init(key: key, value: value, range: nil)
}
public static func rangedAttribute(key: NSAttributedString.Key, value: Any, range: Range<String.Index>) -> Self {
.init(key: key, value: value, range: range)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment