func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cellIdentifier = "ExerciseMenuCell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! ExerciseOptionTableViewCell
let currentWorkout = workouts[indexPath.row]
cell.nameLabel!.text = currentWorkout.name
cell.photoImageView.image = currentWorkout.filename
cell.startWorkout.tag = indexPath.row
cell.startWorkout.addTarget(self, action:Selector("workoutAction:"), forControlEvents: .TouchUpInside)
cell.infoWorkout.tag = indexPath.row
cell.infoWorkout.addTarget(self, action:Selector("infoAction:"), forControlEvents: .TouchUpInside)
return cell
}
Both startWorkout and infoWorkout cause the application to crash with the error message 'unrecognised selector sent to instance'.
Example of code within the button actions. I am trying to return the indexPath of the button so I can then act on that.
@IBAction func workoutAction(sender: AnyObject) {
let buttonTag = sender.tag
print(buttonTag)
}
exact error message:
016-06-17 18:34:30.722 Exercises[4711:245683] - [Exercises.ExerciseMenu beginWorkout:]: unrecognized selector sent to instance 0x7fb47874a4b0 2016-06-17 18:34:30.727 Exercises[4711:245683] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Exercises.ExerciseMenu beginWorkout:]: unrecognized selector sent to instance 0x7fb47874a4b0'
workoutAction
andinfoAction
methods ? – Midhun MPbeginWorkout
method. So I think the crash is happening somewhere else or you edited the actual code and forgot to update the crash log! – Midhun MP