---
title: "pop(to:animated:completion:)"
framework: carplay
role: symbol
role_heading: Instance Method
path: "carplay/cpinterfacecontroller/pop(to:animated:completion:)"
---

# pop(to:animated:completion:)

Removes each template from the navigation hierarchy until the specified template becomes visible.

## Declaration

```swift
func pop(to targetTemplate: CPTemplate, animated: Bool, completion: ((Bool, (any Error)?) -> Void)? = nil)
```

```swift
func pop(to targetTemplate: CPTemplate, animated: Bool) async throws -> Bool
```

## Parameters

- `targetTemplate`: The template to make visible.
- `animated`: If doc://com.apple.documentation/documentation/Swift/true, CarPlay animates the transition between templates.
- `completion`: The closure CarPlay calls after it removes the required templates.

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func pop(to targetTemplate: CPTemplate, animated: Bool) async throws -> Bool For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously. targetTemplate must exist in the navigation hierarchy. You can use templates to access its contents. CarPlay calls completion after it removes the required templates. The Boolean parameter is true if the specified template exists in the navigation hierarchy and CarPlay removes the required templates successfully; otherwise, it’s false and CarPlay provides an error that describes the failure. CarPlay throws an exception if it can’t remove the required templates and you don’t provide a closure.

## See Also

### Adding and Removing Templates

- [pushTemplate(_:animated:completion:)](carplay/cpinterfacecontroller/pushtemplate(_:animated:completion:).md)
- [popTemplate(animated:completion:)](carplay/cpinterfacecontroller/poptemplate(animated:completion:).md)
- [popToRootTemplate(animated:completion:)](carplay/cpinterfacecontroller/poptoroottemplate(animated:completion:).md)
