D. Finna D. Finna - 1 month ago 10
iOS Question

Error when adding cell delegate to class - swift

Why do I get an error, when I add this code?:

, myProfileWorkoutTableViewCellDelegate


To my class?:

class myProfileTableViewController: UITableViewController, UICollectionViewDataSource, UICollectionViewDelegate, myProfileWorkoutTableViewCellDelegate {


This is the beginning of my
myProfileTableViewCell.swift
:

import UIKit
import Firebase
import FirebaseDatabase

protocol myProfileWorkoutTableViewCellDelegate {
func watchTrainingPressed(cell: myProfileWorkoutTableViewCell)
}

class myProfileWorkoutTableViewCell: UITableViewCell {


and this is my button inside the cell:

@IBAction func watchTrainingPressed(sender: AnyObject) {
if let _ = delegate {
delegate?.watchTrainingPressed(self)
}
}

Answer

You need to implement the function

func watchTrainingPressed(cell: myProfileWorkoutTableViewCell)

inside your myProfileTableViewController class.