Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanielCardonaRojas/749cf5b593636fb723de61fbda663fdf to your computer and use it in GitHub Desktop.
Save DanielCardonaRojas/749cf5b593636fb723de61fbda663fdf to your computer and use it in GitHub Desktop.
extension NSMutableAttributedString {
func replacingOccurrences(of item: String, with replacement: NSAttributedString) {
guard let range: Range<String.Index> = self.string.range(of: item) else {
return
}
let nsrange = NSRange(range, in: self.string)
self.replaceCharacters(in: nsrange, with: replacement)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment