How do I handle runtime error in swift? -
i not know how handle runtime error in swift. need check parsing error , it. can me please?
i have code this:
var:someobject = parse("some string")
i need handle generic error occurs in runtime. thanks!
if function yours, in case of failure, can make function return nil value.
that way line of code
var anobj:someobject = parse("some string")
would become this
var:someobject? = parse("some string")
notice ? sign. means value in optional. in simple words, actual value, or nil. after function, should perform check like
if anobj != nil { //do } else { //the parse didn't go right, handle erorr here. }
Comments
Post a Comment