I have a protocol I want some of my UIView subclasses to conform to so they can 
be controlled by a specific master object. So they are UIVIews (class) and they 
are also MasterControllable (protocol)

easy to make those UIView subclasses

public class MyVIew1 : UIView, MasterControllable {}
public class MyView2 : UIView, MasterControllable {}

etc

what I wanted in the master was an array of them, an array of UIViews which are 
also MasterControllable, but I can’t think of a way to specify that

private var myViews : Array<UIView,MasterControllable>                  // nope
private var myViews : Array<T:UIView where T:MasterControllable>        // nope

I can specify an array of something conforming to a protocol, or more than one 
protocol, or of a subclass of a given class, but not it seems of a subclass of 
a given class which also conforms to a given protocol. 

Yes I could write a generic UIView subclass which conforms to the 
MasterControllable protocol and stub out all the protocol methods and then 
write my UIView subclasses as subclasses of that, then use an array of that 
generic class, but that seems a very old scruffy way of doing it. 

I tried thinking about protocol extensions but didn’t get very far with that 
either. 

Did I miss something or has my quest for type perfection led me down another 
blind alley? 





_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to