swift protocol, IBOutlet property cannot have non-object type

后端 未结 6 1080
梦毁少年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

    Not ideal, but an option is to do something like this:

    @IBOutlet var objectType: NSObject!
    
    private var conformingObject: SomeProtocol {
      return objectType as SomeProtocol
    }
    

    Got to make sure your objectType conforms to SomeProtocol or things will explode

提交回复
热议问题