我想在IB中连接一个自定义的swift委托。委托是一个在swift中实现某个协议的对象。
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 ThumbnailTableViewCellDelegate {
func cellWasTouched(thumbnail: Bool, cell: UITableViewCell)
}
class ThumbnailTableViewCell: UITableViewCell {
@IBOutlet var thumbnailTableViewCellDelegate: ThumbnailTableViewCellDelegate?
}
不幸的是,编译器抱怨:
unfortunately, the compiler complains with:
error: 'IBOutlet' property cannot have non-object type 'ThumbnailTableViewCellDelegate'
@IBOutlet var thumbnailTableViewCellDelegate: ThumbnailTableViewCellDelegate?
^~~~~~~~~