Skip to content

andyyhope/Blog_UIStoryboardSafety

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

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages