<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/TaskGroup/addTask(executorPreference:priority:operation:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:ScG7addTask18executorPreference8priority9operationySch_pSg_ScPSgxyYaYAcntF"
  },
  "title" : "addTask(executorPreference:priority:operation:)"
}
-->

# addTask(executorPreference:priority:operation:)

Adds a child task to the group.

```
mutating func addTask(executorPreference taskExecutor: (any TaskExecutor)? = nil, priority: TaskPriority? = nil, operation: sending @escaping @isolated(any) () async -> ChildTaskResult)
```

## Parameters

`taskExecutor`

The task executor that the child task should be started on and keep using.
Explicitly passing `nil` as the executor preference is equivalent to
calling the `addTask` method without a preference, and effectively
means to inherit the outer context’s executor preference.
You can also pass the [`globalConcurrentExecutor`](/documentation/Swift/globalConcurrentExecutor) global executor explicitly.

`priority`

The priority of the operation task.
Omit this parameter or pass `nil` to inherit the task group’s base priority.

`operation`

The operation to execute as part of the task group.

---

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)