I have the following
I wouldn't create this kind of dependency between the cell and the view controller - that makes the architecture more intricate and the cell not reusable.
I suggest you to use the delegation pattern, which may sound a little complicated - although you're already using (
UITableViewDelegate is a typical example):
MyCellProtocolwith one method
didTapCell, accepting a
UITableViewCelland/or some custom data you want to pass to the view controller
var cellDelegate: MyCellProtocol?
didSelectRowAtIndexPathof your cell, call
self.cellDelegate?.didTapCell(), passing the expected parameters
cellForRowAtIndexPathof your view controller, when creating/dequeuing the cell, set its
At this point, when a tap is done in your cell, the
didTapCell method of the view controller is called, and from there you can do whatever you need to achieve.
The key point is: rather than making the cell handle the cell tap/selection, notify the view controller and let it do the job.