var nsRange: NSRange { return .init(location: first ?? 0, length: last ?? 0) }
and it's used in AttributedString.swift this function
@discardableResult
func addAttribute(_ attr: NSAttributedString.Key, _ value: Any, at range: ClosedRange<Int>? = nil) -> AttributedString {
// TODO: check range
let range = range ?? 0..._attributedString.length
_attributedString.addAttribute(attr, value: value, range: range.nsRange)
_updateHandler?(_attributedString)
return self
}
I'm a bit confuse for how I configured the 'range' such as 23 to 24 because I can't pass 23...24 which means it start at 23 but length is 24 or 23...1 which the first should be smaller or equal the last. I need your help.
As the code says in ClosedRange+NSRange:
and it's used in AttributedString.swift this function
I'm a bit confuse for how I configured the 'range' such as 23 to 24 because I can't pass 23...24 which means it start at 23 but length is 24 or 23...1 which the first should be smaller or equal the last. I need your help.