ios - unexpectedly found nil while unwrapping an Optional value On UILabel -
in project have implemented protocol makes url call , return result, , intent show result in uilabel. following code :
protocol restapiresult { func retrivedriverinfo() } class restapicall : restapiresult { func retrivedriverinfo() { self.dashboardviewcontroller.getdriverinfo(driverprofile) // calling function of next view lable setup } }
getdriverinfo in nextview has outlet of textview
class dashboardviewcontroller: uiviewcontroller { override func viewdidload() { super.viewdidload() restdeledate = restapicall() restdeledate!.retrivedriverinfo() // if label set here no error //totaltriplabel.text = "testing" // no error } func getdriverinfo(driverinfoarray : nsarray) { totaltriplabel.text = "testing" // here error } }
if text set in viewdidload() doesn't crash. when tried set value in delegate function crash saying found null.
Comments
Post a Comment