Skip to content

Instantly share code, notes, and snippets.

@benoitjadinon
Created November 7, 2016 09:22
Show Gist options
  • Save benoitjadinon/186a89192b01d8e1c3da36e38e022099 to your computer and use it in GitHub Desktop.
Save benoitjadinon/186a89192b01d8e1c3da36e38e022099 to your computer and use it in GitHub Desktop.
public static class UIStoryboardExtensions
{
// Storyboard.InstantiateViewController<LoginController>()
// instead of :
// Storyboard.InstantiateViewController(nameof(LoginController)) as LoginController
// instead of :
// Storyboard.InstantiateViewController("LoginController") as LoginController
public static T InstantiateViewController<T>(this UIStoryboard @this)
where T : UIViewController
{
return (T)@this.InstantiateViewController(typeof(T).Name);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment