0 Replies
      Latest reply on Jan 13, 2016 12:35 AM by frogcjn
      frogcjn Level 1 Level 1 (20 points)

        Here is a protocol type for some UIViewController,

        protocol  SegueHandlerType {
            var tableView: UITableView! { get }
        }
        
        
        
        
        


         

        so the UITableViewController can conform to the protocal

        extension UITableViewController : SegueHandlerType {
        }
        
        
        
        
        


        It's great!


        What if the tableView is a subclass UITableView?


        like:

        class MyTableView: UITableView {}
        class MyTableViewController:UIViewController {
              @IBOutlet var tableView: MyTableView!
        
        }
        
        
        
        
        



        Then


        extension MyTableViewController:SegueHandlerType {
        
        }
        
        
        
        
        

        will trigger a compiler error.

         

        So the Optional needs a subclass system.

        Or to say, that the template system needs a subclass system.

         

        Optional<UITableView> should be the super class of Optional<MyTableView>

        Array<UITableView> should be the super class of Array<MyTableView>