Why am I getting unrecognized selector sent to class?
<p>I have been going through all stack overflow trying to solve this but none of the solutions work.</p>

<pre><code>class ToastView: UIView {

    static func showInParent(parentView: UIView!, withText text: String, forDuration duration: double_t) {

        //Count toast views are already showing on parent. Made to show several toasts one above another
        var toastsAlreadyInParent = 0;

        for view in parentView.subviews {
            if (view.isKindOfClass(ToastView)) {
                toastsAlreadyInParent++
            }
        }

        var parentFrame = parentView.frame;

        var yOrigin = parentFrame.size.height - getDouble(toastsAlreadyInParent)

        var selfFrame = CGRectMake(parentFrame.origin.x + 20.0, yOrigin, parentFrame.size.width - 40.0, toastHeight);
        var toast = ToastView(frame: selfFrame)

        toast.textLabel.backgroundColor = UIColor.clearColor()
        toast.textLabel.textAlignment = NSTextAlignment.Center
        toast.textLabel.textColor = UIColor.whiteColor()
        toast.textLabel.numberOfLines = 2
        toast.textLabel.font = UIFont.systemFontOfSize(13.0)
        toast.addSubview(toast.textLabel)

        toast.backgroundColor = UIColor.darkGrayColor()
        toast.alpha = 0.0;
        toast.layer.cornerRadius = 4.0;
        toast.textLabel.text = text;

        parentView.addSubview(toast)
        UIView.animateWithDuration(0.4, animations: {
            toast.alpha = 0.9
            toast.textLabel.alpha = 0.9
        })

        var timer = NSTimer.scheduledTimerWithTimeInterval(duration, target: self , selector: "hideSelf:", userInfo: nil,     repeats: false)
        //toast.performSelector(Selector("hideSelf"), withObject: nil, afterDelay: duration)

    }

    static private func getDouble(toastsAlreadyInParent : Int) -&gt; CGFloat {
        return (70.0 + toastHeight * CGFloat(toastsAlreadyInParent) + toastGap * CGFloat(toastsAlreadyInParent));
    }

    func hideSelf( timer: NSTimer) {
        UIView.animateWithDuration(0.4, animations: {
            self.alpha = 0.0
            self.textLabel.alpha = 0.0
            }, completion: { t in self.removeFromSuperview() })
    }

} 
</code></pre>

<p>This is the error I get:</p>

<blockquote>
  <p>NSInvalidArgumentException', reason: '+[HonorsApp.ToastView
  hideSelf:]: unrecognized selector sent to class 0x10b564530'
  *** First throw call stack:</p>
</blockquote>

<p>I have tried adding @objc to the method called from selector and to the class but it has been useless</p>

<p>Also:</p>

<pre><code>Selector("hideSelf")
</code></pre>

<p>declaring the method as <code>hideSelf()</code></p>

<pre><code>Selector("hideSelf:")
</code></pre>

<p>declaring the method as <code>hideSelf( timer: NSTimer)</code></p>

<p>have also checked that the class inherits from NSObject which is accomplished by inheriting from UIView, if I am not wrong.</p>

<p>I am using <code>XCode 6.4</code> and <code>swift 1.2</code></p>

<p>I am new at programming in swift and needed something like the Toast function in android and I found this code but as soon as i hit run the error came up.</p>

<p>Thanks for the help in advance.</p>