RGListKit icon indicating copy to clipboard operation
RGListKit copied to clipboard

Overriding `cellForRowAtIndexPath` with RGListKit?

Open riteshhgupta opened this issue 7 years ago • 3 comments

riteshhgupta avatar Jun 22 '17 02:06 riteshhgupta

Yes we can override any method of any datasource or delegate. For that if you are overriding any implemented method like cellForRowAtIndexPath then you have to create a new subclass of ListManager like, e.g.

class CustomListManager: ListManager {}

extension CustomListManager {

	override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
		//.. your custom logic
		let cell = tableView.dequeueReusableCell(withIdentifier: "customCell", for: indexPath)
		return cell
	}
}

If you simply want to implement a new datasource or delegate then you can simply extend existing ListManager like e.g.,

extension ListManager {

	public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
		// your custom logic
	}
}

riteshhgupta avatar Jun 22 '17 02:06 riteshhgupta

Got it. Makes sense.

bryanbartow avatar Jun 22 '17 02:06 bryanbartow

Awesome!

riteshhgupta avatar Jun 22 '17 02:06 riteshhgupta