title: UITextView change text color of specific text
body: <p>I want to change the text color of a specific text within a UITextView which  matches an index of an array. I was able to slightly modify this <a href="https://stackoverflow.com/a/33088095/5222077">answer</a> but unfortunatly the text color of each matching phrase is only changed once. </p>
  
  <pre><code>var chordsArray = ["Cmaj", "Bbmaj7"]
  func getColoredText(textView: UITextView) -&gt; NSMutableAttributedString {
      let text = textView.text
      let string:NSMutableAttributedString = NSMutableAttributedString(string: text)
      let words:[String] = text.componentsSeparatedByString(" ")
      for word in words {
          if (chordsArray.contains(word)) {
              let range:NSRange = (string.string as NSString).rangeOfString(word)
              string.addAttribute(NSForegroundColorAttributeName, value: UIColor.redColor(), range: range)
          }
      }
      chords.attributedText = string
      return string
  }
  </code></pre>
  
  <p><strong>Outcome</strong><br>
  <img src="https://snag.gy/pF0GS.jpg" alt="outcome"></p>