can @protocol extend @protocol ?
@protocol Prot1 : Prot2
@end
like in java:
public interface Interface1 extends Interface2 {
}
In Swift, you can even extend a protocol to provide implementations of its requirements or add additional functionality that conforming types can take advantage of. For more details, see Protocol Extensions. Extensions can add new functionality to a type, but they can't override existing functionality.
You cannot “extend” a protocol because by definition a protocol doesn't have an implementation - so nothing to extend. (You could say that we “extend a protocol WITH some functionality”, but even an extended protocol is not something we can apply a function to.)
Protocols let you describe what methods something should have, but don't provide the code inside. Extensions let you provide the code inside your methods, but only affect one data type – you can't add the method to lots of types at the same time.
As per Swift documentation, final classes can be extended, but you can not override the already declared methods etc.
Yes, but with the syntax
@protocol Prot1 <Prot2, Prot3, Prot4>
@end
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