Invokes a method of the receiver on the current thread using the specified modes after a delay.
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.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.
An array of strings that identify the modes to associate with the timer that performs the selector. This array must contain at least one string. If you specify
nilor an empty array for this parameter, this method returns without performing the specified selector. For information about run loop modes, see Run Loops in Threading Programming Guide.
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 modes specified by the
modes parameter. 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 one of the specified modes; otherwise, the timer waits until the run loop is in one of those modes.
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 and related methods to get the behavior you want.