<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSApplication/detachDrawingThread(_:toTarget:with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSApplication(cm)detachDrawingThread:toTarget:withObject:"
  },
  "title" : "detachDrawingThread(_:toTarget:with:)"
}
-->

# detachDrawingThread(_:toTarget:with:)

Creates and executes a new thread based on the specified target and selector.

```
class func detachDrawingThread(_ selector: Selector, toTarget target: Any, with argument: Any?)
```

## Parameters

`selector`

The selector whose code you want to execute in the new thread.

`target`

The object that defines the specified selector.

`argument`

An optional argument you want to pass to the selector.

## Discussion

This method is a convenience wrapper for the <doc://com.apple.documentation/documentation/Foundation/Thread/detachNewThreadSelector(_:toTarget:with:)> method of <doc://com.apple.documentation/documentation/Foundation/Thread>. This method automatically creates an `@autoreleasepool` block for the new thread before invoking `selector`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)