I have created a custom cell with its own .m, .h and .xib file. In the cell, I have a UIButton that I added to the xib in IB.
I can receive the IBAction from the UIButton in this custom cell’s .m, but really, I’d like to be forwarding that button press to the main view .m that is hosting the table (and so custom cell) and use an action there.
I’ve spent the last 4 hours attempting various ways of doing this – should I be using NSNotificationCenter? (I’ve tried Notifications lots but can’t get it to work and not sure if i should be persevering)
You need to use delegate in .h file of cell.
Declare the delegate like this
then declare field and property
in .m file
and in button method
Your view controller must adopt this protocol like this
.h file
in .m file in cellForRow: method you need add property delegate to cell
and finally you implement the method from protocol
Sorry for my english, and code. Wrote it from my PC without XCODE