Invokes a method of the receiver on the current thread using the default mode after a delay.
- iOS 2.0+
- macOS 10.0+
- tvOS 9.0+
- watchOS 2.0+
A Selector that identifies the method to invoke. The method should not have a significant return value and should take a single argument of type id, or no arguments.
The argument to pass to the method when it is invoked. Pass
nilif the method does not take an argument.
The minimum time before which the message is sent. Specifying a delay of 0 does not necessarily cause the selector to be performed immediately. The selector is still queued on the thread’s run loop and performed as soon as possible.
This method sets up a timer to perform the
a message on the current thread’s run loop. The timer is configured to run in the default mode (
NSDefault). When the timer fires, the thread attempts to dequeue the message from the run loop and perform the selector. It succeeds if the run loop is running and in the default mode; otherwise, the timer waits until the run loop is in the default mode.
If you want the message to be dequeued when the run loop is in a mode other than the default mode, use the
perform method instead. If you are not sure whether the current thread is the main thread, you can use the
perform method to guarantee that your selector executes on the main thread. To cancel a queued message, use the
This method registers with the runloop of its current context, and depends on that runloop being run on a regular basis to perform correctly. One common context where you might call this method and end up registering with a runloop that is not automatically run on a regular basis is when being invoked by a dispatch queue. If you need this type of functionality when running on a dispatch queue, you should use
dispatch_after and related methods to get the behavior you want.