Specify a class that implements the protocol.

Given the presence of two protocols P1and P2, you can specify the type corresponding to both protocols, for example:

typealias P = protocol<P1, P2>

Is there a similar way to specify a type that is a type of class and also conforms to a protocol, for example. something like this (which doesn't work):

typealias P = UIView: P1
+4
source share
1 answer

Unfortunately, this is not possible in Swift 2.2 and will not be added in Swift 3.0. The idea is that you want to create a rule Typefor types that inherit a certain class and implement the protocol.

Picture

, , , , . POP- , , UIView.


, : enter image description here

: enter image description here

P1Base


P.S. , @property (nonatomic) UIViewController<UITableViewDelegate> *protocolClassProperty; Obj-c, UIViewController! Swift

0

All Articles