Defkalion1
Defkalion1

Reputation: 77

How can I use the custom swipe capabilities of SwipeCellKit for a custom cell created from a .xib file?

I have a custom cell made using a CustomCell.xib as well as a class that goes with it. The way I use it is by registering my custom cell in viewDidLoad():

categoryTableView.register(UINib(nibName: "CustomCell", bundle: nil), forCellReuseIdentifier: "customCell")
configureTableView()

Then I set the cell like this: let cell = tableView.dequeueReusableCell(withIdentifier: "customCell", for: indexPath) as! CustomCategoryCell

Now, I want to use a CocoaPod called SwipeCellKit which makes the cells capable of swiping actions as well as adding an image and making the swipe fully customizable.

In order to use this! I have to change the downcasting of the cell to be as! SwipeTableViewCell.

So my question is: is there a way that I can use both my custom cell and the SwipeCellKit CocoaPod?

My initial thoughts were to go to the table view controller and make the custom cell directly there and not in a custom .xib file, or to copy and paste the code given in the GitHub project.

Any thoughts?

Thank you a lot in advance!

Upvotes: 0

Views: 928

Answers (1)

glyvox
glyvox

Reputation: 58049

You should have SwipeTableViewCell as the superclass of your custom cell instead of UITableViewCell.

import UIKit
import SwipeCellKit

class CustomCell: SwipeTableViewCell {
    [...]
}

Upvotes: 0

Related Questions