title: Highlighting a substring in a UILabel
body: <p>I can;t highlight a substring.Here is what I done(is an "duplicate" question):</p>
  
  <p>Here is where I need to cast it to <strong>NSRange</strong></p>
  
  <pre><code>for user in tweet.userMentions
  {          
      let userName = user.keyword
      if let startIndex = tweetTextLabel.text?.rangeOfString("@")?.startIndex
      {
          let range = startIndex...userName.endIndex
          var atrString = NSMutableAttributedString(string:tweetTextLabel.text!)
          atrString.addAttribute(NSForegroundColorAttributeName, value: UIColor.redColor(), range: range as? NSRange)
          tweetTextLabel.attributedText = atrString
      }
  }
  </code></pre>
  
  <p>What can I do?? Maybe there it is another function thats for swift
  I'm using swift 1.1, iOS 8.1 SDK</p>
  
  <p><strong><em>Update</em></strong>
  Still isn't highliting the text</p>
  
  <pre><code> for user in tweet.userMentions{
  
                  let text = tweetTextLabel.text!
                  let nsText = text as NSString
                  let textRange = NSMakeRange(0, nsText.length)
                  let attributedString = NSMutableAttributedString(string: nsText)
  
                  nsText.enumerateSubstringsInRange(textRange, options: NSStringEnumerationOptions.ByWords, { (substring, substringRange, enclosingRange, stop) -&gt; () in
  
                      if (substring == user.keyword) {
                          attributedString.addAttribute(NSForegroundColorAttributeName, value: UIColor.blueColor(), range: substringRange)
                          println(substring)
                      }
                  })
                  tweetTextLabel.attributedText = attributedString
                  println(attributedString)
  </code></pre>
  
  <p><strong><em>Another update</em></strong>
  So where I updated the code still doesn't colour the substring
  I'm doing a twitter app that highlights with colors hashtags, urls and user screen names</p>