Created
September 14, 2016 01:53
-
-
Save rickbdotcom/3d4afaf60f65fdf0e6adeb1ab8f8006f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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! |
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
nice one! how did you manage to find this?