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

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

php - Prepared Statement Inner Join Cannot Pass Parameter by Reference -

c# - Value cannot be null or empty.\r\nParameter name: name -