I have a `ViewController` class embedded with `tableView` in which I created two `cells` 

First:

```
class CategoryTableViewCell: UITableViewCell {

//MARK:- IBOUTLETS
//MARK:-
@IBOutlet weak var collectionView: UICollectionView!

var categoryArray: [PopularCategories]! {
    didSet {
        self.collectionView.reloadData()
    }
}

override func awakeFromNib() {
    super.awakeFromNib()

    collectionView.delegate = self
    collectionView.dataSource = self
}

override func setSelected(_ selected: Bool, animated: Bool) {
    super.setSelected(selected, animated: true)
}

}

```

In which I created I created a `CollectionViewCell`.
And in my 2nd `TableViewCell` class I `reloaded` the `data` which is coming from the `api`.

This is `collectionView` code inside `TableViewCell` class

```
extension CategoryTableViewCell: UICollectionViewDataSource, UICollectionViewDelegate {

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {

    return categoryArray.count
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

    guard let cell = self.collectionView.dequeueReusableCell(withReuseIdentifier: "CatergoriesCollectionViewCell", for: indexPath) as? CatergoriesCollectionViewCell else {
        return UICollectionViewCell()
    }
    cell.nameLabel.text = categoryArray[indexPath.item].name
    cell.image.sd_setImage(with: URL(string: categoryArray[indexPath.item].image ), placeholderImage: UIImage(named: "placeholderSmall"))
    return cell
}

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {

        func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {

    let cell = self.collectionView.dequeueReusableCell(withReuseIdentifier: "CatergoriesCollectionViewCell", for: indexPath) as! CatergoriesCollectionViewCell
    collectionCellTapHandler?()
    let id = categoryArray[indexPath.item].id
   self.categroyID = id
    controller.categoryId = id
    controller.filterDataUsingMostPopularCategory(id: id, lat: Latitude, long: Longitude)
    print("Here I can access my view controller....\(controller.categoryId)")
    print(cell.nameLabel.text!, id)
}
}

}

```

Now what I want I need to call a function which is in my `ViewController` when select a `collectionView` `cell` item. This the function in my `ViewController` class file I want to access when `collectionViewCell` is selected

```
class OneStopShopVC: TruckerConveyBaseVC {

    func searchDataFromFilteredApi() {

    let param: [String : Any] = ["lat": self.latitude, "lng": self.longitude, "title": selectedTitle, "category": "\(selectedCategory)"]
    print(param)
    CommonUtils.showHudWithNoInteraction(show: true)

    Alamofire.request(Constants.BASE_URL+"search_home_ads.php", method: .post, parameters: param, encoding: URLEncoding.default, headers: nil).responseJSON { (response:DataResponse<Any>) in

        CommonUtils.showHudWithNoInteraction(show: false)
        switch(response.result) {
        case .success(_):
            if let json = response.result.value as? [String:Any] {
                print(json)
                if let ads_list = json["ads_list"]  as? [[String:Any]] {
                    self.adsListModel.removeAll()
                    let response = kSharedInstance.getArray(withDictionary: ads_list)
                    print(response)
                    self.adsListModel = response.map{ AdsListModel(with: $0) }
                }
                DispatchQueue.main.async {
                    self.reloadList()
                }
            }

            break

        case .failure(_):
            print("Error")
            break

        }
    }
}
} 

```

Here is code inside UITableViewDataSource and Delegate

```
extension OneStopShopVC : UITableViewDataSource, UITableViewDelegate {

func numberOfSections(in tableView: UITableView) -> Int {
    return 2
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    if section == 0 {
        return 1
    } else {
        return Int.getInt(self.adsListModel.count)
    }
}

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    if indexPath.section == 0 {
        return 181
    } else {
        return 121
    }
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    return cellConfig(indexPath)
}

private func cellConfig(_ indexpath : IndexPath) -> UITableViewCell {

    if indexpath.section == 0 {

        guard let cell = oneStopShopTableView.dequeueReusableCell(withIdentifier: CategoryTableViewCell.cellIdentifier()) as? CategoryTableViewCell else {
            return UITableViewCell()
        }
        cell.categoryArray = popularCategories

        cell.collectionCellTapHandler = {[weak self] in
            self?.filterDataUsingMostPopularCategory(id: cell.categroyID, lat: Latitude, long: Longitude)
        }

        cell.collectionView.reloadData()
        return cell
    }
    else {

        let cell = oneStopShopTableView.dequeueReusableCell(withIdentifier: OneStopShopTableCell.cellIdentifier()) as! OneStopShopTableCell
        cell.lblPostTitle.text = String.getString(self.adsListModel[indexpath.row].post_title)
        cell.lblPostedDate.text = String.getString(self.adsListModel[indexpath.row].posted_date)
        cell.lblPostedExpDate.text = String.getString(self.adsListModel[indexpath.row].posted_expired_date)
        cell.lblPostedDesc.text = String.getString(self.adsListModel[indexpath.row].post_desc)
        cell.postedImage.sd_setImage(with: URL(string: adsListModel[indexpath.row].post_image ?? ""), placeholderImage: UIImage(named: ""))
        let status = String.getString(self.adsListModel[indexpath.row].status)
        if (status == "Publish") {
            cell.statusLabel.text = "Published"
            cell.statusLabel.textColor = #colorLiteral(red: 0.2745098174, green: 0.4862745106, blue: 0.1411764771, alpha: 1)
        }
        else if(status == "Banned") {
            cell.statusLabel.textColor = UIColor.darkGray
        }
        else {
            cell.statusLabel.textColor = UIColor.red
        }

        cell.priceLabel.text = "$\(String.getString(self.adsListModel[indexpath.row].price))"

        return cell
    }

  }

```

Conclusion: When I click on `CollectionViewCell` item in first `TableViewCell` class I want to reload the data of `SecondTableViewCell`.. For that I need to access `ViewController` function to reload data. How can I do this?

[![enter image description here](https://i.stack.imgur.com/JcGBN.png)](https://i.stack.imgur.com/JcGBN.png)