title: How to pass data from Rear_View to Front_view by delegate using SWRevealViewController?
body: <p>I have a SWRevealViewController and I have a UITableView in my Front_View and UICollectionView in my Rear_View. So when I tap on a Front_View Table Cell then my Rear_View will open and my requirement is when I will tap on a Rear_View Collection Cell then I want to pass index and control has to come in Front_View.</p>
  
  <p>I mean according to my rear_view Collection Cell didSelect action, data would populate in my front_view. I am not able to pass data from rear_View to front_view. I tried by delegate but using SWReveal I am not able to send data.
  Normally I know how to pass data by delegate. </p>
  
  <p>Here is my code:</p>
  
  <p>Front View:</p>
  
  <pre><code>//Cell For Row At IndexPath
  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
      //Assign Cell
      let cellIdentifier:String = "SelectCategory"
      var cellFeeds:SelectCategory? = tableView.dequeueReusableCell(withIdentifier: cellIdentifier) as? SelectCategory
  
      if (cellFeeds == nil)
      {
          var nib:Array = Bundle.main.loadNibNamed("SelectCategory", owner: self, options: nil)!
          cellFeeds = nib[0] as? SelectCategory
      }
  
      cellFeeds?.selectionStyle = .none
  
  
      //For Two cells rear View will open
      if (indexPath.row == 0 || indexPath.row == 1)
      {
          //self.revealViewController().rightViewRevealWidth = 0.0
          self.revealViewController().rightViewRevealOverdraw = 0.0
          self.revealViewController().bounceBackOnOverdraw = false
  
          cellFeeds?.btnDropDown.addTarget( self.revealViewController(), action:#selector(SWRevealViewController.rightRevealToggle(_:)) , for: UIControlEvents.touchUpInside)
  
          self.view.addGestureRecognizer(self.revealViewController().tapGestureRecognizer())
      }
  
      return cellFeeds!
  }
  
  //Table view row select method
  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
      //Assign Cell
      let cellIdentifier:String = "SelectCategory"
      let cellFeeds:SelectCategory? = tableView.dequeueReusableCell(withIdentifier: cellIdentifier) as? SelectCategory
  
      if(0 == indexPath.row || 1 == indexPath.row)
      {
          //Open Rear View.
          revealViewController().rightRevealToggle(animated: true)
      }
  }  
  
  
  //Delegate of Rear View
  extension AddProductView : didTapOnSubCategory {
    func tapOnCategory(index: Int) {
        print("Index Tap is :-  \(index)")
    }
  }  
  
  
  //Declare the delegate
  override func viewWillAppear(_ animated: Bool) {
      super.viewWillAppear(animated)
     let vc = GetAddProductDataView()
      vc.delegate = self
  
      tableView.reloadData()
  }  
  </code></pre>
  
  <p>Rear_View :-  </p>
  
  <pre><code>//Declare protocol.
  protocol didTapOnSubCategory {
    func tapOnCategory(index : Int)
  }  
  
  class GetAddProductDataView: UIViewController,SWRevealViewControllerDelegate {
  
    //TableView
    @IBOutlet var tableView: UITableView!
  
    //Collection View
    @IBOutlet var collectionView: UICollectionView!
  
    //Category Label
    @IBOutlet var categoryLabel: NSLayoutConstraint!
  
    //Declare Delegate
    var delegate : didTapOnSubCategory?
  
    //View Did Load
    override func viewDidLoad() {
        super.viewDidLoad()
  
      //Add Gesture to Swipe Reveal
        self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
        revealViewController().delegate = self
  
      //Delegate of tableView
      tableView.delegate = self
      tableView.dataSource = self
  
      collectionView.delegate = self
      collectionView.dataSource = self
  
      //tableView.isHidden = false
      collectionView.isHidden = true
    }  
    //Select the CollectionView Cell
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  
       delegate?.tapOnCategory(index: indexPath.row)
  
       let gotoFrontView = self.storyboard?.instantiateViewController(withIdentifier: "SWAddProductView") as! SWRevealViewController
  
      revealViewController().setFront(gotoFrontView, animated: true)
      revealViewController().frontViewPosition = FrontViewPosition.left
     }
  }
  </code></pre>
  
  <p>So in my front_View and rear_view you can see that everything is fine but I am not able to pass index from rear_View (class GetAddProductDataView) to front_View.</p>