When I try this I get error:
class ViewController: UIViewController, UIScrollViewDelegate {
......
}
extension ViewController: UIScrollViewDelegate { // Error: Redundant conformance of 'ViewController' to protocol 'UI
....
}
When I try this I don't get error:
class ViewController: UIViewController {
......
}
extension ViewController: UIScrollViewDelegate { // No error
...
}
Why do I not add UIScrollViewDelegate to ViewController when I use extension?
If a class is type of UIViewController means it conforms to UIScrollViewDelegate ?
In the first code sample, you've already added conformance to UIScrollViewDelegate
with the class declaration.
Now, when you try to conform to UIScrollViewDelegate
again with the extension, swift screams at you.
For the second code sample the conformance is added in the extension. The class did not conform to UIScrollViewDelegate
before the extension was added.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments