I have a string like this:

Your score is %@.

I want the string to become :

Your score is perfect.

I was thinking to use:

let attrs = [NSAttributedString.Key.font : UIFont.boldSystemFont(ofSize: 15)]
let boldAttributedString = NSMutableAttributedString(string: "perfect".localized(), attributes: attrs)
String(format: "Your string is %@.", boldAttributedString) 

I know my way around NSMutableString and attributed strings, but I'm not sure if it's possible because I have no way of doing a count of words, because in other languages it might be shorter or in a different order... The value for "perfect" is coming from an enum value.

Any ideas on how to approach this issue?

Related posts

Recent Viewed