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

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -