0

im sending an array of response from one view to another view but by tagging value of tapped header giving pressed function as shown below

func pressed(_ sender: UIButton) {

        let ViewAllVC : ViewAllViewController = self.storyboard?.instantiateViewController(withIdentifier: "VIEWALLID") as! ViewAllViewController

        ViewAllVC.navigationStringName = "View All"


        ViewAllVC.viewAllArray = productDetailsArray[sender.tag] as! NSArray

        self.sideMenuViewController?.contentViewController = UINavigationController(rootViewController: ViewAllVC)

    }

and in destination view I am setting image for the image view in the cell as follows

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
    {
        let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath) as! ViewAllCell
         if navigationStringName == "View All"
         {

        let URLBaseString = "http://vehiclebuzzzz.com/"

        let url = URL(string:URLBaseString .appending((viewAllArray[i] as AnyObject).value(forKey: "img_name") as? String)


                let dataurl = try? Data(contentsOf: url!)

                cell.productImageView?.image = UIImage(data: dataurl!)



                }
return cell
}

and it is showing for particular category is selected not for all

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
  • Possible duplicate of [What does "fatal error: unexpectedly found nil while unwrapping an Optional value" mean?](http://stackoverflow.com/questions/32170456/what-does-fatal-error-unexpectedly-found-nil-while-unwrapping-an-optional-valu) –  Mar 01 '17 at 06:34
  • on which line it is crashing ? – Varun Naharia Mar 01 '17 at 06:37
  • How does `ViewAllVC.viewAllArray` get set? – Paulw11 Mar 01 '17 at 06:57
  • it is crashing at let URLBaseString = "http://vehiclebuzzzz.com/" let url = URL(string:URLBaseString .appending((viewAllArray[i] as AnyObject).value(forKey: "img_name") as? String) let dataurl = try? Data(contentsOf: url!) cell.productImageView?.image = UIImage(data: dataurl!) – yerra sai roja Mar 02 '17 at 07:54

0 Answers0