swift - getting "unexpectedly found nil" AFTER performing nil check -
despite checking nil, getting fatal error: unexpectedly found nil while unwrapping optional value
error being caught in conditional (first line below)
if (obj.prop != nil && obj.prop?.otherprop != nil) { anotherobj.yetanotherprop = (obj.prop?.otherprop nsurl).absolutestring }
i have tried if let
follows (xcode highlights 2nd let being unexpected nil found):
if let obja = obj.prop, let otherprop = obja.otherprop { anotherobj.yetanotherprop = (otherprop nsurl).absolutestring }
why don't either of these work?!
i getting source object (obj
in both cases above) 3rd party library written in objective c. suspecting checking nil wrong somehow?
so in writing think sort of figured out. don't knwo why first 1 doesn't work, second works as:
if let obja = obj.prop, let otherprop = obja?.otherprop { anotherobj.yetanotherprop = (otherprop nsurl).absolutestring }
Comments
Post a Comment