Skip to content

Instantly share code, notes, and snippets.

@maxcampolo
Created April 28, 2016 16:01
Show Gist options
  • Save maxcampolo/b36680f16b8a58d0626c57232290955f to your computer and use it in GitHub Desktop.
Save maxcampolo/b36680f16b8a58d0626c57232290955f to your computer and use it in GitHub Desktop.
Performing selector after delay and cancelling previous perform requests in Swift.
// Perform selector
self.performSelector(#selector(MyViewController.myFunction(_:)), withObject: myObject, afterDelay: 1.0)
// Cancel perform requests
self.classForCoder.cancelPreviousPerformRequestsWithTarget(self, selector: #selector(MyViewController.myFunction(_:)), object: myObject)
// Note: -
// myObject can be nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment