Xcode 7 Swift 2 impossible to instantiate UIViewController subclass of generic UITableViewController

前端 未结 2 1008
别那么骄傲
别那么骄傲 2020-12-04 02:23

I have a generic class:

class PaginatedTableViewController
  

        
相关标签:
2条回答
  • 2020-12-04 02:39

    It is possible if you manually load your generic VC into Objective-C runtime manually via the load() method i.e. call. PaginatedTableViewController.load() in your app delegate's init method. Idea from https://stackoverflow.com/a/43896830/671580

    0 讨论(0)
  • 2020-12-04 02:47

    Unfortunately, generic Swift classes are not visible to Objective-C code and also are not supported in Interface Builder (in storyboards and xibs). I find these two points closely related.

    As a solution I would suggest you to use aggregation: do not make you view controller generic, but extract some logic to another (generic) class and use it inside your view controller.

    0 讨论(0)
提交回复
热议问题