Instance Method

performSelector:target:argument:order:modes:

Schedules the sending of a message on the receiver.

Declaration

- (void)performSelector:(SEL)aSelector target:(id)target argument:(id)arg order:(NSUInteger)order modes:(NSArray<NSRunLoopMode> *)modes;

Parameters

aSelector

A selector that identifies the method to invoke. This method should not have a significant return value and should take a single argument of type id.

target

The object that defines the selector in aSelector.

anArgument

The argument to pass to the method when it is invoked. Pass nil if the method does not take an argument.

order

The priority for the message. If multiple messages are scheduled, the messages with a lower order value are sent before messages with a higher order value.

modes

An array of input modes for which the message may be sent. You may specify custom modes or use one of the modes listed in Run Loop Modes.

Discussion

This method sets up a timer to perform the aSelector message on the receiver at the start of the next run loop iteration. 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.

This method returns before the aSelector message is sent. The receiver retains the target and anArgument objects until the timer for the selector fires, and then releases them as part of its cleanup.

Use this method if you want multiple messages to be sent after the current event has been processed and you want to make sure these messages are sent in a certain order.

See Also

Scheduling and Canceling Messages

- cancelPerformSelector:target:argument:

Cancels the sending of a previously scheduled message.

- cancelPerformSelectorsWithTarget:

Cancels all outstanding ordered performs scheduled with a given target.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software