---
title: "addTask(name:executorPreference:priority:operation:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/taskgroup/addtask(name:executorpreference:priority:operation:)"
---

# addTask(name:executorPreference:priority:operation:)

Adds a child task to the group.

## Declaration

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

## Parameters

- `name`: Human readable name of this task.
- `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 doc://com.apple.Swift/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.

## See Also

### Adding Tasks to a Task Group

- [addTask(priority:operation:)](swift/taskgroup/addtask(priority:operation:).md)
- [addTask(name:priority:operation:)](swift/taskgroup/addtask(name:priority:operation:).md)
- [addTask(executorPreference:priority:operation:)](swift/taskgroup/addtask(executorpreference:priority:operation:).md)
- [addTaskUnlessCancelled(name:executorPreference:priority:operation:)](swift/taskgroup/addtaskunlesscancelled(name:executorpreference:priority:operation:).md)
- [addTaskUnlessCancelled(executorPreference:priority:operation:)](swift/taskgroup/addtaskunlesscancelled(executorpreference:priority:operation:).md)
- [addTaskUnlessCancelled(name:priority:operation:)](swift/taskgroup/addtaskunlesscancelled(name:priority:operation:).md)
- [addTaskUnlessCancelled(priority:operation:)](swift/taskgroup/addtaskunlesscancelled(priority:operation:).md)
- [addImmediateTask(name:priority:executorPreference:operation:)](swift/taskgroup/addimmediatetask(name:priority:executorpreference:operation:).md)
- [addImmediateTaskUnlessCancelled(name:priority:executorPreference:operation:)](swift/taskgroup/addimmediatetaskunlesscancelled(name:priority:executorpreference:operation:).md)
