Hello! Made the Like button in the header section. When you click, the button does not work and the clicks are not summarized. Tell me how to embed a button in the header, or maybe I didn’t specify something inside the button function. I found an example in appcoda a lesson instagramm-like Parse server. I will be very grateful for the help. It produces such an error. It seems that everything has been set correctly, I have already tried to change the function inside the button. Already in the storyboard I have unnecessary functions and deleted it with errors. Can anyone help? Here is my code:
import UIKit class CustomSoccerHeaderView: UITableViewHeaderFooterView { var clickBravisso: Soccer? @IBOutlet weak var bravoBtn: UIButton!{ didSet { bravoBtn.layer.cornerRadius = bravoBtn.frame.size.width/2 bravoBtn.layer.masksToBounds = true } } @IBOutlet weak var countBravo: UILabel! @IBAction func likeBtn(_ sender: UIButton) { if (clickBravisso != nil) { if var clickBravissimo: Int = clickBravisso!.object(forKey: "bravissimo") as? Int { clickBravissimo += 1 clickBravisso!.setObject(clickBravissimo, forKey: "bravissimo") clickBravisso!.saveInBackground() countBravo.text = "\(clickBravissimo)" } } } @IBOutlet weak var nameHeader: UILabel! @IBOutlet weak var imageHeader: UIImageView! override func awakeFromNib() { super.awakeFromNib() // Initialization code } } func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let header = tableView.dequeueReusableHeaderFooterView(withIdentifier: "CustomSoccerHeaderView") as! CustomSoccerHeaderView header.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 280) header.bravoBtn.tag = section header.nameHeader.text = detailSoccer.detailTitleS header.countBravo.text = "\(detailSoccer.bravissimo)" header.bravoBtn.addTarget(self, action: #selector(CustomSoccerHeaderView.likeBtn(_:)), for: .touchUpInside) detailSoccer.imagePrS.getDataInBackground { (data, error) in header.imageHeader.image = error == nil ? UIImage(data: data!) : nil } return header }