swift protocol, IBOutlet property cannot have non-object type

后端 未结 6 1074
梦毁少年i
梦毁少年i 2020-12-15 20:11

I would like to wire up a custom swift delegate in IB. The delegate is an object that implements a certain protocol in swift.

protocol ThumbnailTableViewCel         


        
6条回答
  •  北海茫月
    2020-12-15 21:07

    You can in connect your own protocols in IB with this workaround. It's a known issue with Xcode, so will probably be solved one day. Until then:

    1. Declare the delegate as an AnyObject - @IBOutlet var delegate:AnyObject!
    2. Connect the delegate in Interface Builder
    3. Change the outlet's type to your protocol, e.g. @IBOutlet var delegate:MyDelegate

    This works for me.

提交回复
热议问题