Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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()

About

Example code for a blog post i wrote on Medium

Resources

Stars

97 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages