I have a piece of code that turns a string into a Text with attributes like italics, bold, etc. I apply attributes per character (or perhaps per stringIndex depending on the language) and then join everything using
.reduce(Text(""), {t1, t2 in t1 + t2 }).
The thing is that this had been working great (last time it worked was 7th September 2020), but now it turned out that is just stopped to work only for strikethrough(). It still works fine for bold(), italics() and underline().
I have iOS 14.1 installed on my iPhone and I build the project in xCode for iOS 14.0.
Looks like something might have changed in the underlying API for the strikethrough method.
The input string is in the following format:
where
It works as follows:
For instance for a string l~o^l^~ it should produce:
and then
I can swear that this worked and I haven't touched the code.
Is there any place where I can find a change log if there have been any changes to this part of the API? I tried to reproduce with a minimal example in another project, but so far it is working there so I need to keep digging.
.reduce(Text(""), {t1, t2 in t1 + t2 }).
The thing is that this had been working great (last time it worked was 7th September 2020), but now it turned out that is just stopped to work only for strikethrough(). It still works fine for bold(), italics() and underline().
I have iOS 14.1 installed on my iPhone and I build the project in xCode for iOS 14.0.
Looks like something might have changed in the underlying API for the strikethrough method.
The input string is in the following format:
Code Block orange -> ein orang~er~ Wagen (^ein orang~eer~ Wagen^)
where
Code Block ~ - underline ^ - strikethrough
It works as follows:
I go through string indices to extract which indices have attributes, where the function returns the following type:
For instance for a string l~o^l^~ it should produce:
Code Block [ 1: [~], 2: [~], 3: [^, ~], 4: [^], 5: [~], 6: [~] ]
then I go through the string using its .indices, I discards the signs themselves and then apply attributes if the index is present in the aforementioned mapping of indices to attributes like this:
Code Block func createAttributeText(str: String) -> Text { let attributeIndices: [String.Index: Set<Character>] = ... return str.indices.map { index in if let attributes = attributeIndices[index] { /* returns e.g. Text(str).strikethrough() or Text(str).bold().strikethrough() */ return applyAttrs(text: str, attrs: attrs) else { return Text(str) } } .reduce(Text(""), {t1, t2 in t1 + t2 }) }
and then
Code Block VStack { createAttributedText(str: someStringVariable) }
I can swear that this worked and I haven't touched the code.
Is there any place where I can find a change log if there have been any changes to this part of the API? I tried to reproduce with a minimal example in another project, but so far it is working there so I need to keep digging.