I have a UITableView
which is made up of my own custom UITableViewCell
s, subclassed as CustomCell
. I add a UITextField
to that cell and a method runs on certain events (from the text field).
When this method runs, I need to access the CustomCell
that the text field is a subview of.
So I thought, how can I access the parent view of the text field (the CustomCell
)?
I have tried this, get the text field, the sender of the method, then from that get its superview.
CustomTextField *textField = sender;
CustomCell *cell = (CustomCell *)[textField superview];
However this fails, when I try to access a property of my cell, the app crashes and I get this in the console: [UIView myLabel]: unrecognized selector sent to instance
. (myLabel
is the property I am trying to access on the cell.)
Why doesn't this work, or is there an alternative method of accessing that cell?