Last active
August 21, 2018 19:59
-
-
Save DanielCardonaRojas/749cf5b593636fb723de61fbda663fdf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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