Safe Segues in Swift

Hardcoded Strings? That’s wrong (man)

Steven Curtis
The Startup

--

Photo by Tim Evans on Unsplash

Difficulty: Beginner | Easy | Normal | Challenging

Segues are great ways to traverse view controllers using storyboards, but they expose us to a danger.

This article gives us several methods in order to create “safe segues”.

Interested? Read on.

Prerequisites:

  • Be able to produce a “Hello, World!” iOS application (guide HERE)
  • Know about Segues in iOS applications (guide HERE)

Some knowledge of the following would be useful, but don’t feel you need every feature of Swift to read the article!

  • Understand the use or Enums in Swift (guide HERE)
  • Be able to use Protocols (guide HERE)
  • Knowledge of assertions (guide HERE)
  • Case statements are used later (guide HERE)
  • Later on in this article associated types are used with protocols (guide HERE) which would benefit from understanding of Raw Representable (guide HERE)

Terminology

Character: A character, usually associated with a letter of the alphabet

--

--