Q: How to load in each row of a tableView an object tied to a different element of an array I have a viewController with a tableView where i would like that in each row load a place of the array var places: [QPlace] = []associate to a different element of the array var categories: [QCategoryy?]? = [] (i'm working with google places). This is my class 
import UIKit
import CoreLocation
import Social
import AVFoundation


private let resueIdentifier = "MyTableViewCell"


extension UIViewController {
    func present(viewController : UIViewController, completion : (() -> ())? = nil ){
        if let presented = self.presentedViewController {
            presented.dismiss(animated: true, completion: {
                self.present(viewController, animated: true, completion: completion)
            })
        } else {
            self.present(viewController, animated: true, completion: completion)
        }
    }
}


class CourseClass2: UIViewController, UITableViewDelegate, UITableViewDataSource {





    @IBOutlet weak var tableView: UITableView!

    var locationManager:CLLocationManager?
    let minimumSpacing : CGFloat = 15 //CGFloat(MAXFLOAT)
    let cellWidth: CGFloat = 250
    var radius = 3000 // 3km
   /* var category : QCategoryy? */
    var categories: [QCategoryy?]? = []
    var currentLocation : CLLocationCoordinate2D?
    var places: [QPlace] = []
    var isLoading = false
    var response : QNearbyPlacesResponse?
    var rows = 0
    var numberPlaces = 0
    let queue = TaskQueue()

    override func viewDidLoad() {
        super.viewDidLoad()
       print(categories)
        for category in categories! {
            queue.tasks +=~ { result, next in

            }

            queue.tasks +=! {

                self.tableView.reloadData()
            }

            queue.run {

            }
         title = category?.name
    }
        tableView.dataSource = self
        tableView.delegate = self
        numberPlaces = HomeClass.globalLimit

    }


    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        determineMyCurrentLocation()
    }

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
    }



    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)


        rows = 0
     /*   insertRowsMode3()  */

         for category in categories! {
            queue.tasks +=~ { result, next in
                // Add your places request here

            }

            queue.tasks +=! {

                // reloadData
                self.tableView.reloadData()
            }

            queue.run {
                // check your places array is correct
            }
        category?.markView()
    }
}



func canLoadMore() -> Bool {
        if isLoading {
            return false
        }

        if let response = self.response {
            if (!response.canLoadMore()) {
                return false
            }
        }

        return true
    }

    func loadPlaces(_ force:Bool) {

        if !force {
            if !canLoadMore() {
                return
            }
        }

        print("load more")
        isLoading = true
         for category in categories! {
            queue.tasks +=~ { result, next in
                // Add your places request here

            }

            queue.tasks +=! {

                self.tableView.reloadData()
            }

            queue.run {
                // check your places array is correct
            }
        NearbyPlaces.getNearbyPlaces(by: category?.name ?? "food", coordinates: currentLocation!, radius: radius, token: self.response?.nextPageToken, completion: didReceiveResponse)

       }
    }



    func didReceiveResponse(response:QNearbyPlacesResponse?, error : Error?) -> Void {
        if let error = error {
            let alertController = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .alert)
            let actionDismiss = UIAlertAction(title: "Dismiss", style: .cancel, handler: nil)
            let actionRetry = UIAlertAction(title: "Retry", style: .default, handler: { (action) in
                DispatchQueue.main.async {
                    self.loadPlaces(true)
                }
            })
            alertController.addAction(actionRetry)
            alertController.addAction(actionDismiss)
            DispatchQueue.main.async {
                self.present(viewController: alertController)

            }
        }
        if let response = response {
            self.response = response
            if response.status == "OK" {
                if let placesDownloaded = response.places {
                    places.append(contentsOf: placesDownloaded)
                }

               self.tableView?.reloadData()
            } else {
                let alert = UIAlertController.init(title: "Error", message: response.status, preferredStyle: .alert)
                alert.addAction(UIAlertAction.init(title: "Cancel", style: .cancel, handler: nil))
                alert.addAction(UIAlertAction.init(title: "Retry", style: .default, handler: { (action) in
                    DispatchQueue.main.async {
                        self.loadPlaces(true)
                    }
                }))
                 self.present(viewController: alert)
            }
            isLoading = false
        }
        else {
            print("response is nil")
        }
    }



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

        print("numberOfsection Call")
        return 1
    }





    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

        print("numberOfRows Call")
        if places.count < self.numberPlaces {

        return  places.count   /*  rows   */
        }
       return self.numberPlaces
    }



    public  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell = tableView.dequeueReusableCell(withIdentifier: resueIdentifier, for: indexPath) as! MyTableViewCell


        let place = places[indexPath.row]
        cell.update(place: place)

        if indexPath.row == places.count - 1 {
            loadPlaces(false)
        }
        print("CellForRow Call")
        return (cell)


    }




     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {




        tableView.deselectRow(at: indexPath, animated: true)

        UIView.animate(withDuration: 0.2, animations: {
        let cell = tableView.dequeueReusableCell(withIdentifier: "MyTableViewCell", for: indexPath) as! MyTableViewCell
    })
         performSegue(withIdentifier: "goToLast" , sender: indexPath)

    }




    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {


     return 100
}

My problem is that every time when i run the application in the tableView load all places of a single (casually) element of the array categories, so what i think is that i have to modify maybe this cycle  
for category in categories! {
            queue.tasks +=~ { result, next in
                // Add your places request here

            }

            queue.tasks +=! {

                // reloadData
                self.tableView.reloadData()
            }

            queue.run {
                // check your places array is correct
            }
        category?.markView()
    } 

because in my class there is nothing that consider that the array categories can have more than one element inside. How can i do to create a cycle which load in every row a place of a different element of categories ? If this is useful, is the struct of category 
struct QCategoryy {
    var name:String
    var isSelected = false
    init(name:String) {
        self.name = name
    }
}

extension QCategoryy: ExpressibleByStringLiteral {
    init(stringLiteral value: String) {
        self.name = value
    }
    init(unicodeScalarLiteral value: String) {
        self.init(name: value)
    }
    init(extendedGraphemeClusterLiteral value: String) {
        self.init(name: value)
    }
}

