Skip to content

Instantly share code, notes, and snippets.

@rickbdotcom
Created September 14, 2016 01:53
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rickbdotcom/3d4afaf60f65fdf0e6adeb1ab8f8006f to your computer and use it in GitHub Desktop.
Save rickbdotcom/3d4afaf60f65fdf0e6adeb1ab8f8006f to your computer and use it in GitHub Desktop.
// need to define these inits so you can instantiate a dummy object in code (and coder init is required as well)
class ArrayTableViewController<T>: UITableViewController {
init() { super.init(style: .Plain) }
required init?(coder aDecoder: NSCoder) { super.init(coder:aDecoder) }
class OffersTableViewController: ArrayTableViewController<Offer> {
required init?(coder aDecoder: NSCoder) { super.init(coder:aDecoder) }
override init() { super.init() }
// then instantiate a dummy object
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
let _ = OffersTableViewController() // after this call this viewcontroller would load fine from a storyboard!
@pegurov
Copy link

pegurov commented Apr 15, 2017

nice one! how did you manage to find this?

@rusito-23
Copy link

In my case I didn't have to instantiate the dummy object at all, but I'm not happy with having to create a new XIB for every class, the only thing that remains Generic is the TableViewController.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment