Last active
December 20, 2017 14:21
-
-
Save EfraimB/b7605f4f2aea3c2615be691dcddd87a2 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 NSAttributedString { | |
func replacing(placeholder:String, with valueString:String) -> NSAttributedString { | |
if let range = self.string.range(of:placeholder) { | |
let nsRange = NSRange(range,in:valueString) | |
let mutableText = NSMutableAttributedString(attributedString: self) | |
mutableText.replaceCharacters(in: nsRange, with: valueString) | |
return mutableText as NSAttributedString | |
} | |
return self | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment