Mastering instantiateInitialViewController: A Guide to Efficient iOS Storyboard Navigation

Including one gotcha

Steven Curtis
5 min readFeb 22, 2024
Photo by Chris Scott on Unsplash

It took Apple until iOS13 to allow us to use instantiateInitialViewController(). Here is a guide about that, but also one gotcha you might fall into.

Docs: https://developer.apple.com/documentation/uikit/uistoryboard/1616213-instantiateinitialviewcontroller

Difficulty: Beginner | **Easy** | Normal | Challenging<br/>

This article has been developed using Xcode 15.0, and Swift 5.9

Terminology:

Storyboard: A way to graphically layout the UI in Xcode

UINavigationController: A container that stores view controllers in a stack

Introduction

Storyboards are a visual representation of the user interface. Personally I’d prefer to programatically instantiate view controllers yet work constrains often mean you need to work with storyboards.

Before iOS 13, developers had to navigate a more cumbersome path to inject properties in a view controller meaning that it’s difficult to understand the requirements of any particular view controller. Leveraging instantiateInitialViewController() means developers can understand the…

--

--