0

I am facing an issue with replacing some characters in an attributed string with some attributed characters.

let replaceString = NSMutableAttributedString(string: playerNames[index], attributes: attributes)

taskText.mutableString.replaceOccurrences(of: searchString[Int(index)], with: playerNames[index], options: .caseInsensitive, range: NSRange(location: 0, length: taskText.length))

The problem is, that I can't add the replaceString to the replaceOccurrences function because I can't use attributed strings here. Is there any method other method?

I just want to replace some "#1" and "#2" strings with some names like "Anna" but with bold font to make it more visible.

Stefan Me
  • 5
  • 4
  • Find the range, then call https://developer.apple.com/documentation/foundation/nsmutableattributedstring/1417045-replacecharacters where you'll have set Anna with bold font for instance. – Larme Apr 04 '20 at 15:26
  • Ahhh thanks! I missed to just find the range and replace them afterwards. thanks! – Stefan Me Apr 04 '20 at 16:15

0 Answers0