detachNewThreadSelector(_:toTarget:with:)
Detaches a new thread and uses the specified selector as the thread entry point.
Declaration
class func detachNewThreadSelector(_ selector: Selector, toTarget target: Any, with argument: Any?)Parameters
- selector:
The selector for the message to send to the target. This selector must take only one argument and must not have a return value.
- target:
The object that will receive the message
aSelectoron the new thread. - argument:
The single argument passed to the target. May be
nil.
Discussion
The objects aTarget and anArgument are retained during the execution of the detached thread, then released. The detached thread is exited (using the exit() class method) as soon as aTarget has completed executing the aSelector method.
If this thread is the first thread detached in the application, this method posts the NSWillBecomeMultiThreaded with object nil to the default notification center.