Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save huguesbr/f7ef6a64def4a40dbf9bf28ae840625c to your computer and use it in GitHub Desktop.
Save huguesbr/f7ef6a64def4a40dbf9bf28ae840625c to your computer and use it in GitHub Desktop.
FrenchKit 2016 Conference Talk Proposal - Simplifying your View Controller using Enum

Enum is probably one of the most powerful feature of Swift. It's simple, yet it allow to easily build complex Finite State Machine. Let's explore how to extract View Controller's state dependant logic into enum and how to test it separatly.

View Controller often take different state depending of some specific state of the App (fetching data, user logged in/off, ...). This can lead to some internal test condition which clutter your code and are also hard to test. Wrapping up this logic into an enum with associated values allow to split this UI logic piece from the rest of the View Controller logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment