I have Two Class One is ViewController and second is UITableViewCell IN tableview Cell I have created one Tapable link label . Label Delegates method to call my protocol method but its not working Here is my code 1)ViewController
public protocol DataEnteredDelegate: class { func userDidEnterInformation(info: NSString) } class ChatViewController: UIViewController{ override func viewDidLoad() { } func userDidEnterInformation(info: NSString) { print(info) } } 2)UITableViewCell
class UIChatBubbleTableViewCell: UITableViewCell,TapLabelDelegate { var delegate_of_link:DataEnteredDelegate? = nil func tapLabel(tapLabel: TapLabel, didSelectLink link: String) { print(link) if (delegate_of_link != nil) { delegate_of_link!.userDidEnterInformation(link) } } } Where I am doing a mistake if Protocol is not working then I have to use Notification Center Please, give me some solution.
cell.delegate_of_link = <your_view_controller>have you done that?delegate_of_link = nilthat should be assigned some valid value. I assume you are creating somecellin your view controller snippet 1. so there after creating a cell you must assign self todelegate_of_linkso the method you defined in view controller gets called. Before doing that i suggest you check some tutorials on creating custom protocols.