             }
             
         } else {
-            if let selectedLinkRangeResult = selectedLinkRangeResult {
-                attributedText = addLinkAttributesToAttributedString(attributedText, withLinkRangeResults: [selectedLinkRangeResult], highlighted: false)
+            if let selectedLinkRangeResult = selectedLinkRangeResult, attributedText = attributedText {
+                self.attributedText = addLinkAttributesToAttributedString(attributedText, withLinkRangeResults: [selectedLinkRangeResult], highlighted: false)
             }
             
             selectedLinkRangeResult = nil

        var rangesForLinkType = [LinkRangeResult]()

        // Setup a regular expression for user handles and hashtags
        var error: NSError?
        let regex = NSRegularExpression(pattern: regexPattern, options: .CaseInsensitive, error: &error)

        // Run the expression and get matches
        let length: Int = count(text)
        if let matches = regex?.matchesInString(text, options: .ReportCompletion, range: NSMakeRange(0, length)) {

            // Add all our ranges to the result
            for match in matches {
                if let textCheckingResult = match as? NSTextCheckingResult {
                    let matchRange = textCheckingResult.range
                    let stringIndexRange = advance(text.startIndex, matchRange.location)..<advance(text.startIndex, matchRange.location + matchRange.length)
                    let matchString = text.substringWithRange(stringIndexRange)
                    
                    rangesForLinkType.append(LinkRangeResult(linkDetectionType: linkType, linkRange: stringIndexRange, linkString: matchString, textLink: nil))
                }
            }
        }


        textContainer.size = CGSizeMake(CGRectGetWidth(self.bounds), CGFloat.max)
    }
    
    public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        if let linkRangeResult = getLinkRangeResultWithTouches(touches) {

            selectedLinkRangeResult = linkRangeResult
