(Since AttributedString
relies heavily on quite a few of Swift's features like dynamicMemberLookup
, it's the most "Swifty" API I have seen. So I think this is appropriate for this forum.)
I need help figuring out this very basic operation on AttributedString
:
let n = 1234567.898
let s = n.formatted(.number.precision(.fractionLength(2)).attributed)
s
now is an AttributedString
: 1,234,567.90
I need to break apart s
into two AttributedString
parts:
1,234,567.
(<== includes the decimalSeparator)
90
I think it's just simply calling subscript<R>(bounds: R) -> AttributedSubstring
?
But I can't figure out how to get the two index Range
's. I know how to get the decimalSeparator
run. But how to come up with the two index Range
's?