Value of optional type '[AnyObject]?' must be unwrapped to a value of type '[AnyObject]'
I am passing value of one array to another array
first array declared
var arrayShow = [AnyObject]()
second array declared
var arrayData = [AnyObject]()
i m getting crash here : i have to make below line as options and remove ! @vadian vc.arrayData = (self.arrayShow[tag] as? [AnyObject])!
My Code :
let status = self.nullToNil(value: result["status"]) as? String ?? ""
let doc_url = self.nullToNil(value: result["doc_url"]) as? String ?? ""
self.arrayShow.removeAll()
if(status == "200"){
let data = self.nullToNil(value: result["data"]) as? [[String:AnyObject]]
self.arrayShow.append(data as AnyObject)
print("Array : \(self.arrayShow)")
DispatchQueue.main.async {
if(data?.count == 0){
self.alert(message: "No Data Found.")
}else{
if let vc = self.storyboard?.instantiateViewController(withIdentifier: "ViewPrescriptionReport") as? ViewPrescriptionReport {
vc.modalPresentationStyle = .overCurrentContext
vc.strTitle = "View Prescription"
vc.strURL = doc_url
vc.arrayData = (self.arrayShow[tag] as? [AnyObject])!
self.present(vc, animated:true, completion: nil)
}
}
}
}
else{
print("no data found")
}