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?
Swift version: 5.6. The override is used when you want to write your own method to replace an existing one in a parent class. It's used commonly when you're working with UIViewControllers , because view controllers already come with lots of methods like viewDidLoad() and viewWillAppear() .
You can prevent a method, property, or subscript from being overridden by marking it as final. Do this by writing the final modifier before the method, property, or subscript's introducer keyword (such as final var , final func , final class func , and final subscript ).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With