Swift protocols: method does not override any method from its superclass

Vitalii Vashchenko picture Vitalii Vashchenko · Jun 24, 2014 · Viewed 75.5k times · Source

Since Xcode 6 still has a lots of bugs with Swift, I'm not sure is it one or I'm missing something. My class adopts protocol NSLayoutManagerDelegate. But it seems impossible to override method I need. I do as documentation describes:

override func layoutManager(_ aLayoutManager: NSLayoutManager!,
        didCompleteLayoutForTextContainer aTextContainer: NSTextContainer!,
        atEnd flag: Bool) {

    }

But I get error here: method does not override any method from its superclass. What should I do?

Answer

Ken Thomases picture Ken Thomases · Jun 24, 2014

You're implementing a method from the protocol, yes, but it's not an override. Just remove the override keyword. An override is when your superclass also implements that method and you're providing a version that replaces or modifies the behavior of the superclass implementation. That's not what's happening here.