ios - Swift unwrapping optional giving error with data -
my ios application fetch data server , render images data using 'kingfisher', problem whenever add or replace new image on server application crashes due code below error : "fatal error: unexpectedly found nil while unwrapping optional value"
let prfix:string = "my_prefix_url /\(org.image)" celimage.kf_setimagewithurl((nsurl(string: prfix))!)
please check sceeenshot more detail don't undestand why getting error, because can see prfix
got value.
i think due prefix
contain unnecessary characters, can fix urlhostallowedcharacterset
you can fix prefix
malformed url (swift 2.x).
let urlstr : nsstring = prfix.stringbyaddingpercentencodingwithallowedcharacters(.urlhostallowedcharacterset())! celimage.kf_setimagewithurl((nsurl(string: urlstr string))!)
this make sure url contains string.
Comments
Post a Comment