i trying head around swift , have doubt.
if let cn = respobj["cabnumber"].string !cn.isempty { booking.cabnumber = cn }
i understand check string being nil or not happen in case if response object doesnot have cabnumber key , object pair in it. using swiftyjson.
it must be:
if let cn = respobj["cabnumber"] as? string !cn.isempty { booking.cabnumber = cn }
in there, expression let cn = respobj["cabnumber"] as? string
check whether key cabnumber
exists in dictionary. second expression where ! cn.isempty
checks whether value empty string.
note, if cabnumber
key exists has json null value, return instance of nsnull
instead of nil.
Comments
Post a Comment