<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/ThrowingTaskGroup/addTask(name:priority:operation:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Scg7addTask4name8priority9operationySSSg_ScPSgxyYaKYAcntF"
  },
  "title" : "addTask(name:priority:operation:)"
}
-->

# addTask(name:priority:operation:)

Adds a child task to the group.

```
mutating func addTask(name: String?, priority: TaskPriority? = nil, operation: sending @escaping @isolated(any) () async throws -> ChildTaskResult)
```

## Parameters

`name`

Human readable name of this task.

`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.

## Discussion

This method doesn’t throw an error, even if the child task does.
Instead, the corresponding call to `ThrowingTaskGroup.next()` rethrows that error.

---

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)