Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

283
Views
Could not cast value of type 'UITableViewCell' to 'SwipeCellKit.SwipeTableViewCell'

I'm trying to use a pod called SwipeCellKit in my project, where this pod add a class called SwipeTableViewCell. What I have done so far is:

  • Create a view controller to the storyboard.
  • Create a UIViewController class.
  • Import SwipeCellKit to the Swift file.
  • Assign view controller to the class.
  • Add table view to the view controller.
  • Connect delegate and data source from table view to the view controller.
  • Add prototype cell to the table view, and named it "cell" for its reusable identifier.
  • Change the cell class into SwipeTableViewCell.
  • Add table view delegate to the view controller.
  • Add numberOfRows and cellForRow function to my UIViewController class.

This is the implementation of the cellForRow:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! SwipeTableViewCell;
    return cell;
}

But I got error on the let cell = ..., saying:

Could not cast value of type 'UITableViewCell' to 'SwipeCellKit.SwipeTableViewCell'

Why? And how to fix this? I think I have arranged everything as it should be. Did I miss something?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

What solved the problem for me:

In Main.Storyboard (or where you have your views), make sure that everywhere you want to use the reusable "cell", in the Identity Inspector on the right pane, you have the following:

  • Class is set to SwipeTableViewCell
  • Module is set to SwipeCellKit.
over 4 years ago · Santiago Trujillo Report

0

You need to create your own Cell class as subclass of SwipeTableViewCell then you need to implement SwipeTableViewCellDelegate protocol in your ViewController

and for this line

let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! SwipeTableViewCell

you should use your class name which is a SwipeTableViewCell subclass

example

let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! MySwipeableCell
cell.delegate = self
over 4 years ago · Santiago Trujillo Report

0

I created the following example

import UIKit
import SwipeCellKit

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {


    @IBOutlet weak var tableView: UITableView!

    override func viewDidLoad() {
        super.viewDidLoad()
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 4
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! SwipeTableViewCell
        return cell
    }

}


class SwipeTableViewCellSubClass: SwipeTableViewCell {

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

}

set the class for your view to be SwipeTableViewCellSubClass.

this should work perfectly for you. good luck

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!