0

There is an error in addTarget of buttonSandK

I Check the reference outlet and it's connected+

if i remove addtarget, the code run. What am i missing here

enter image description here

public protocol tenorFooterDelegate: AnyObject{
    func tapSK(message : String)
}

class TenorFooterView: UICollectionReusableView {
    @IBOutlet weak var buttonSandK : Button!
    
    weak var delegate : tenorFooterDelegate!
    var message : String?
    override func awakeFromNib() {
        super.awakeFromNib()
        
        buttonSandK.addTarget(self, action: #selector(onTapLaunch(_:)), for: .touchUpInside)
        
       
    }
    
    @objc
    func onTapLaunch(_ sender: UIButton){
       // self.delegate.tapSK(message: message ?? "")
    }
    
    func configure(with data: String) {
       message = data
    }
}
Loka
  • 41
  • 5
  • 1
    I can see TenorFooterView class assigned to root view and a child of it. You can remove the class from child view and check. – ChanOnly123 Mar 17 '22 at 06:20
  • 1
    I know it's not strictly an answer to the question, but anyway. If you use outlets, why not assigning also `@IBAction` to your button instead of `addTarget`? – lazarevzubov Mar 17 '22 at 07:52

1 Answers1

0

You are using

@IBOutlet weak var buttonSandK : Button!

but I think You should change it to

@IBOutlet weak var buttonSandK : UIButton!
stoikokolev
  • 484
  • 5
  • 9