How to add protocol type as subview
问题 So I wrote a simple protocol: protocol PopupMessageType{ var cancelButton: UIButton {get set} func cancel() } and have a customView: class XYZMessageView: UIView, PopupMessageType { ... } and then I currently have: class PopUpViewController: UIViewController { //code... var messageView : CCPopupMessageView! private func setupUI(){ view.addSubview(messageView) } } But what I want to do is: class PopUpViewController: UIViewController { //code... var messageView : PopupMessageType! private func