     var tapRecognizer: UITapGestureRecognizer!
     weak var delegate: MentionTapHandlerDelegate?
 
-    init(view: UIView, delegate: MentionTapHandlerDelegate) {
+    init<T: UIView where T: AttributedTextContainingView>(view: T, delegate: MentionTapHandlerDelegate) {
         super.init()
         self.delegate = delegate
         tapRecognizer = UITapGestureRecognizer(target: self, action: "viewTapped:")

        // Decode
        let attributedStringWithMentions = mentionDecoder.decode()

        switch view {
        case let label as UILabel:
            label.attributedText = attributedStringWithMentions
        case let textView as UITextView:
            textView.attributedText = attributedStringWithMentions
        case let textField as UITextField:
            textField.attributedText = attributedStringWithMentions
        default:
            print("unsupported view")
        }

        // Handle Taps
        tapHandler = MentionTapHandler(view: view, delegate: self)

    static let Encoded = "MentionEncodedAttribute"
}

/**
 *  AttributedTextContainingView provides a single interface for text containing views
 */
public protocol AttributedTextContainingView {
    var m_text: String { get }
    var m_attributedText: NSAttributedString? { get set }
    var m_font: UIFont { get }
    var m_textColor: UIColor { get }
}

extension UILabel: AttributedTextContainingView {
    public var m_text: String {
        get {
            return text ?? ""
        }
    }

    public var m_attributedText: NSAttributedString? {
        set {
            attributedText = newValue
        }
        get {
            return attributedText
        }
    }

    public var m_font: UIFont {
        return font
    }

    public var m_textColor: UIColor {
        return textColor
    }
}

extension UITextField: AttributedTextContainingView {
    public var m_text: String {
        get {
            return self.text ?? ""
        }
    }

    public var m_attributedText: NSAttributedString? {
        set {
            self.attributedText = newValue
        }
        get {
            return self.attributedText
        }
    }

    public var m_font: UIFont {
        return font!
    }

    public var m_textColor: UIColor {
        return textColor!
    }
}

extension UITextView: AttributedTextContainingView {
    public var m_text: String {
        get {
            return self.text ?? ""
        }
    }

    public var m_attributedText: NSAttributedString? {
        set {
            self.attributedText = newValue
        }
        get {
            return self.attributedText
        }
    }

    public var m_font: UIFont {
        return font!
    }

    public var m_textColor: UIColor {
        return textColor!
    }
}

///  The MentionController class provides a simple interface for rendering @mentions and #hashtag comments on UILabel, UITextField, and UITextView.
///  To handle user taps on an @mentioin or #hashtag you must conform to the MentionTapHandlerDelegate protocol and set the delegate on MentionController.
///  Note: MentionController is built to be compatible objective C.
public class MentionController: NSObject, MentionTapHandlerDelegate {

    var view: AttributedTextContainingView
    weak var delegate: MentionTapHandlerDelegate?
    private var tapHandler: MentionTapHandler!
    private let mentionDecoder: MentionDecoder

    // MARK: Init

    /**
    Public initializer for MentionController.

    - parameter view:     A `UIView` that conforms to `AttributedTextContainingView`
    - parameter delegate: An object that conforms to MentionTapHandlerDelegate

    - returns: An instance of MentionController
    */
    public convenience init<T: UIView where T: AttributedTextContainingView>(view: T, delegate: MentionTapHandlerDelegate?) {
        let attributedString = view.m_attributedText ?? NSAttributedString(string: view.m_text, attributes: [NSFontAttributeName : view.m_font, NSForegroundColorAttributeName : view.m_textColor])
        self.init(view: view, inputString: attributedString, delegate: delegate)
    }

    private init<T: UIView where T: AttributedTextContainingView>(view: T, inputString: NSAttributedString, delegate: MentionTapHandlerDelegate?) {
        self.view = view
        self.delegate = delegate
        self.mentionDecoder = MentionDecoder(attributedString: inputString)
