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 detailerror screenshot 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

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -