Created
February 19, 2018 18:39
-
-
Save chriswill0w/7f802aa334baa78b431960788c7d18c1 to your computer and use it in GitHub Desktop.
This file contains 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 { | |
@discardableResult | |
func setAsLink(_ textToFind: String, linkURL: String) -> Bool { | |
let foundRange = mutableString.range(of: textToFind) | |
guard foundRange.location != NSNotFound else { return false } | |
addAttribute(NSAttributedStringKey.link, value: linkURL, range: foundRange) | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment