title: Images In a Collection View
body: <p>I am coding in Swift 3.2, and inside of a TableView Controller have a TableView (scrolling vertically), and each row of the table holds a CollectionView (scrolling horizontally).</p>
  
  <p>I am not sure if it is acceptable coding practice, but I made my ViewController class inherit <code>UITableViewController</code> <em>and</em> <code>UICollectionViewDelegate</code> and <code>UICollectionViewDataSource</code>.</p>
  
  <p>For now, I have a hard coded array of image names and would like three images to scroll horizontally in each collection view, with each row having distinct images. However, as of now each row shows the same three images ("11.png", "12.png", "13.png"), and I was wondering how to fix this.</p>
  
  <p>Below is my <code>ViewController</code> class.</p>
  
  <pre><code>//for the tableView
  let event = generateRandomData()
  
  override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      return event.count
  }
  
  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
      let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
      return cell
  }
  
  override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
      guard let tableViewCell = cell as? TableViewCell else { return }
      tableViewCell.setCollectionViewDataSourceDelegate(self, forRow: indexPath.row)
  }
  
  
  //for the collectionView
  var images: [String] = [
      "11.png", "12.png", "13.png",
      "21.png", "22.png", "23.png",
      "31.png", "32.png", "33.png",
      "41.png", "42.png", "43.png",
      "51.png", "52.png", "53.png",
      "61.png", "62.png", "63.png",
      "71.png", "72.png", "73.png",
      "81.png", "82.png", "83.png",
      "91.png", "92.png", "93.png",
      "101.png", "102.png", "103.png",
  ]
  
  func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      return 3
  }
  
  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      collectionView.isPagingEnabled = true;      //makes the horizontal scrolling have no bounce and relatively have a better snap
  
      let myCell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionViewCell", for: indexPath as IndexPath) as! CollectionViewCell
      let myCellImage = UIImage(named: images[indexPath.row])
      myCell.eventImage.image = myCellImage
  
      return myCell
  }
  </code></pre>
  
  <p>I am an amateur coder, so any help is greatly appreciated!</p>