Q:

How can I disable a button for a few seconds after it is tapped

The following is the code for an IBAction I would like to disable for 5 seconds after it is clicked.
@IBAction func postPressed(sender: AnyObject) {
        //var disableMyButton = sender as? UIButton
        //disableMyButton!.enabled = false
        //NSTimer.scheduledTimerWithTimeInterval(5, target: self, selector:"enableButton", userInfo: nil, repeats: false)
    if(currLocation != nil){
        let testObject = PFObject(className: "Hey")
        testObject["text"] = self.postView.text
        testObject["count"] = 0
        testObject["replies"] = 0            
        testObject["location"] = PFGeoPoint(latitude: currLocation!.latitude , longitude: currLocation!.longitude)
        testObject["comments"] = []
        testObject["user"] = PFUser.currentUser()
        testObject.saveInBackgroundWithBlock({ (success, error) -> Void in
            if success {
                self.dismissViewControllerAnimated(true , completion: nil)
                if let completion = self.completion {
                    completion(self)
                }
            }
        })
    } else {
        alert()
    }  
}

The commented out code is my attempt at disabling the button for 5 seconds, but this code crashes, and I believe it crashed because there is no reference to the enable button.
Typically I would do something like 
func enableButton() {
   self.button.enabled = true
}

But this won't work since it's an IBAction and theres no reference to the button besides there. Maybe there is a way to do so, but I'm at a loss.
Thanks in advance for some help.

A:

Try this,

while tap the action set button disable. 
set some interval to enable
your button by using delay function.

Ex:
let tapGesture = UITapGestureRecognizer(target: self, action: "tapaction")
tapGesture.numberOfTapsRequired = 1
Your_Button_name.addGestureRecognizer(tapGesture)

@IBAction func tapaction()
{
    Your_Button_name.disable=true
    //Delay function to enable your button
    NSTimer.scheduledTimerWithTimeInterval(Your_time_value_delay, target: self, selector: Selector("enablefunc"), userInfo: nil, repeats: false)
}

func enablefunc()
{
   Your_Button_name.disable=false
}

