Why I can not inherit from multiple classes in swift just like it's library classes

前端 未结 1 1686
一向
一向 2020-12-08 06:58

I try to create myPet by inherit from two classes but error for example:

import UIKit
class SecondViewController: UIViewController, UITextFieldDelegate {
            


        
相关标签:
1条回答
  • 2020-12-08 07:23

    Swift does not support multiple inheritance, following Objective C in this. This is NOT inheritance from two classes:

    class SecondViewController: UIViewController, UITextFieldDelegate
    

    It is inheritance from one class UIViewController and adopting the UITextFieldDelegate protocol. Read about protocols at https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Protocols.html

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