Error: Redundant conformance of 'ViewController' to protocol with extension

John

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 ?

Sam

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.

edited at
0

Comments

0 comments
Login to comment

Related

Swift : Redundant conformance of Viewcontroller to protocol UIGestureRecognizerDelegate

Xcode 7 beta 5 Swift 2 redundant conformance to protocol error

**Redundant conformance of 'FlickrPhotosViewController' to protocol 'UICollectionViewDataSource'**

Redundant conformance of 'TableViewController' to protocol 'UITableViewDataSource'

Protocol Conformance Extension for some UIControls

Redundant conformance of 'NSDate' to protocol 'Comparable' Swift

Redundant conformance of TableView to protocol UITableViewDataSource with Xib Files

Redundant conformance error message Swift 2

Swift protocol conformance by extension between frameworks

Redundant conformance of 'CLLocationCoordinate2D' to protocol 'decodable'/'encodable'

Redundant conformance of <view controller> to protocol 'UISearchBarDelegate' - Swift 4

Swift multi-protocol conformance, compilation error

Redundant Conformance Error In ViewControllers that has UINavigationControllerDelegate after Importing an external library

Is it possible to add type constraints to a Swift protocol conformance extension?

Conditional Protocol Conformance to Protocol

Dynamic protocol conformance in Swift

Conditional protocol conformance?

associatedtype protocol conformance issues

Protocol conformance not recognized in generic function

Swift protocol conformance with async overload

Protocol conformance with implicitly unwrapped optionals

Workaround for simple protocol inheriting conformance

Swift protocol conformance requirements for subtypes

Is protocol conformance in method parameters optional?

Clean Swift / VIPER protocol conformance

ViewController does not conform to protocol AnyObject error with UISwipeGestureRecognizer

Swift 3 protocol extension using selector error

Swift 2.2 #selector in protocol extension compiler error

Swift 2 add protocol conformance to protocols