Skip to content

Instantly share code, notes, and snippets.

View gragera's full-sized avatar

Alberto Gragera gragera

View GitHub Profile
@gragera
gragera / gist:fab8a2eaa11dc63b9b9f
Last active September 3, 2018 13:15
Using swift generics for easier storyboard ViewController instantiation
import UIKit
extension UIStoryboard {
func instantiate<T>(identifier: String, asClass: T.Type) -> T {
return instantiateViewControllerWithIdentifier(identifier) as! T
}
func instantiate<T>(identifier: String) -> T {
return instantiateViewControllerWithIdentifier(identifier) as! T