title: How to reload data in table view by tapping the cell of collection view in swift
body: <p>Am developing a app using swift in my in one controller am using both collection view and table view.collection view which kept at top of the controller which scrolls horizontally and contains near 10 cells and table view is just kept below to the collection view.i have passed the  json(api) data to both collection and table view now i have to call another json data(another api) which is subcategory of before  first json data and then if i tapp the cell of collection view it should call the second api and reload the table view again to display second api data...how to do this task??</p>
  
  <pre><code>func jsonParsingFromURL () {
      Alamofire.request(.POST, "http://something.com", parameters: nil, encoding: .URL, headers: nil).response { (req, res, data, error) -&gt; Void in
          // print(res)
          // print(data)
  
          let dataString = NSString(data: data!, encoding:NSUTF8StringEncoding)
          print(dataString)
          self.startParsing(data!)
          self.collecStartParsing(data!)
      }        
  }
  func startParsing(data :NSData)
  {
      let dict: NSDictionary!=(try! NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers)) as! NSDictionary
      for i in 0  ..&lt; (dict.valueForKey("subcategory") as! NSArray).count
      {
          arrDict.addObject((dict.valueForKey("subcategory") as! NSArray) .objectAtIndex(i))
      }
      SecondTableView.reloadData()
  }
  
  func collecStartParsing(data :NSData){
      let dict: NSDictionary!=(try! NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers)) as! NSDictionary
      for i in 0  ..&lt; (dict.valueForKey("subcategory_icons") as! NSArray).count
      {
          collectionitems.addObject((dict.valueForKey("subcategory_icons") as! NSArray) .objectAtIndex(i))
      }
      FirstCollectionView.reloadData()
  }    
  </code></pre>
  
  <p>my datasource method of table and collection view:</p>
  
  <pre><code>func tableview cell for row at indexpath {
  
      let cell = tableView.dequeueReusableCellWithIdentifier("SegueCell") as! SecondTableViewCell
  
      let strTitle:NSString = arrDict[indexPath.row] .valueForKey("adtitle") as! NSString
  
      cell.TitleLabel.text = strTitle as String
  
      return cell
  </code></pre>
  
  <p>collection view:</p>
  
  <pre><code>func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {
  
      let cell = collectionView.dequeueReusableCellWithReuseIdentifier("FirstCollectionView", forIndexPath: indexPath) as! FirstCollectionViewCell
  
  
      let strTitle:NSString = collectionitems[indexPath.item] .valueForKey("subcategoryname") as! NSString
  
  
      cell.TitleLabel.text = strTitle as String
  
      return cell
  </code></pre>
  
  <p>It helps to call first api and passing data.now am having another api for that I have written different function:</p>
  
  <pre><code>func jsonParsingForIcon () {
      Alamofire.request(.POST, "http://www.mysecondapi.com", nil, encoding: .URL, headers: nil).response { (req, res, data, error) -&gt; Void in
          // print(res)
          // print(data)
  
          let dataString = NSString(data: data!, encoding:NSUTF8StringEncoding)
          print(dataString)
      }
  
  }
  </code></pre>
  
  <p>both the json(api) has same key value pair now by tapping cell of collection view should call the second api function and reload my table view according to the second api json data.</p>
  
  <p>mr.bista answer should be accepted....</p>
  
  <p>Just we need to remove the array i.e.,myarray.removeallobjects()</p>