Perform an action after a delay in iOS

Today I had to perform an action (play a sound file) when a user touches a button, but only do so after half a second had passed. Luckily iOS has very good support for this.

[self performSelector:@selector(playAudio)
           withObject:nil
           afterDelay:0.5f];

This is a method on NSObject which also has a bunch of similar methods for all different use cases.

Happy coding.

Tags: iOS, Objective-C