I am following this tutorial http://www.raywenderlich.com/62435/make-swipeable-table-view-cell-actions-without-going-nuts-scroll-views to create a customized table cell. But I am using swift instead of objective c.
Here is my table cell view in swift.
protocol SwipeableCellDelegate {
func buttonOneActionForItemText(itemText: NSString)
func buttonTwoActionForItemText(itemText: NSString)
}
class MyTableViewCell: UITableViewCell {
@IBOutlet weak var button1: UIButton!
@IBOutlet weak var button2: UIButton!
@IBOutlet weak var mytextLabel: UILabel!
@IBOutlet weak var testLabel: UILabel!
var delegate: SwipeableCellDelegate
init(delegate: SwipeableCellDelegate) {
self.delegate = delegate
super.init()
}
required init(coder aDecoder: NSCoder) {
// fatalError("init(coder:) has not been implemented")
super.init(coder : aDecoder)
}
}
But it does not compile, I get error saying :
MyTableViewCell.swift:38:9: Property 'self.delegate' not initialized at super.init call
And if I get rid of "init(coder aDecoder: NSCoder)", I get error saying 'required' initializer 'init(coder:)' must be provided by subclass of UITableViewCell'.
I have read this thread Class does not implement its superclass's required members
about what to do in my required init(coder aDecoder: NSCoder).
But I can't get the code to compile.
I appreciate if someone can help me.
Thank you.