Skip to content

Latest commit

 

History

History
32 lines (19 loc) · 712 Bytes

README.md

File metadata and controls

32 lines (19 loc) · 712 Bytes

UIStoryboard: Safer with Enums, Protocol Extensions and Generics

Because String literals are so yucky.

Medium post

UIStoryboard: Safer with Enums, Protocol Extensions and Generics

tl;dr

Turn this:

let name = "News"

let storyboard = UIStoryboard(name: name, bundle: nil)

let identifier = "ArticleViewController"

let viewController = storyboard.instantiateViewControllerWithIdentifier(identifier) as! ArticleViewController

viewController.printHeadline()

Into this:

let storyboard = UIStoryboard.storyboard(.News)

let viewController = storyboard.instantiateViewController(ArticleViewController.self)

viewController.printHeadline()