Top "Swift-protocols" questions

Protocols specific to the Swift language

Protocol func returning Self

I have a protocol P that returns a copy of the object: protocol P { func copy() -> Self } and …

swift protocols subclassing swift-protocols
what is 'where self' in protocol extension

I saw so many examples with below format extension Protocolname where Self: UIViewController What is where Self in protocol extension. …

swift protocols swift-protocols swift-extensions
How to conform to a protocol's variables' set & get?

I'm playing around with protocols and how to conform to them. protocol Human { var height: Int { get set } } struct Boy: …

ios swift protocols getter-setter swift-protocols
Why I can't use let in protocol in Swift?

I have a doubt about protocols in Swift about the use of var and the keywords { get set }. From Apple …

ios swift protocols getter-setter swift-protocols
Pass data between ViewController and ContainerViewController

I'm working on an app, and need to pass data between view and containerView. I need to send data and …

swift swift2 segue uistoryboardsegue swift-protocols
Non-'@objc' method does not satisfy optional requirement of '@objc' protocol

Overview: I have a protocol P1 which provides a default implementation of one of the Objective-C optional functions. When I …

swift swift3 swift-protocols
How can I call a static function on a protocol in a generic way?

Is there a point to declaring a static function on a protocol? The client using the protocol has to call …

swift protocols swift-protocols
Protocol doesn't conform to itself?

Why doesn't this Swift code compile? protocol P { } struct S: P { } let arr:[P] = [ S() ] extension Array where Element : P { …

swift generics swift-protocols
When to use `protocol` and `protocol: class` in Swift?

I have setup a protocol to send some information back to the previous VC. I define it like this: protocol …

swift swift-protocols
"fatal error: array cannot be bridged from Objective-C"—Why are you even trying, Swift?

I have declared a Swift protocol: protocol Option { var name: String { get } } I declare multiple implementations of this protocol—some …

ios swift swift-protocols