nextResponder in Swift 3

本秂侑毒 提交于 2019-12-04 19:17:47

You can override the variable:

override var next: UIResponder? {
    get {
        // do something
        return super.next
    }
}

As the variable is defined as a read-only variable, implementing didSet doesn't make sense. You're not supposed to set this variable. Instead, different subclasses of UIResponder can override the variable and return different values. The base class returns nil.

Note: The variable is called next in Swift 3 and nextResponder in Objective-C and earlier Swift versions. This can be seen in the documentation when you switch between Swift and Objective-C in the right column.

nextResponder is replaced by next in Swift 3. Its new declaration is:

var next: UIResponder? { get }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!