Navigation & Passing Data

June 02, 2026 1 min read

A UINavigationController manages a stack of screens with the familiar back button.

Push a new screen

let detail = DetailVC()
detail.userId = 42      // pass data forward
navigationController?.pushViewController(detail, animated: true)

Go back / present modally

navigationController?.popViewController(animated: true)
// modal
present(SettingsVC(), animated: true)

Passing data back

Use a closure or a delegate to send results back to the previous screen.

// in DetailVC
var onDone: ((String) -> Void)?
// caller sets detail.onDone = { result in ... }

Summary

Navigation controllers manage a screen stack. Pass data forward via properties and back via closures/delegates.