简体   繁体   中英

Redundant conformance of Object to Protocol

I have this error Redundant conformance of 'AnyView' to protocol 'Pressable' when attempt to run the below code. Could anyone shows the error or any other way to perform the same login with protocols.

class AnyView: UIView, Pressable {

}

// MARK: - Pressable

protocol Pressable: UIView {

}

extension UIView: Pressable {
    // touchesBegan
    override open func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
        scaleAnimation(value: 0.8)
    }
}

You simply need to get rid to the AnyView conformance to Pressable , since its superclass, UIView already conforms to Pressable .

class AnyView: UIView {

}

// MARK: - Pressable

protocol Pressable: UIView {

}

extension UIView: Pressable {
    // touchesBegan
    override open func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
        scaleAnimation(value: 0.8)
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM