Swift, error EXC_BREAKPOINT (code=1, subcode=0x100310448) -


this error code. if delete last "!" on imagedata, error also... how fix it..

if let crew = user!["crew"] as? [string:any], let crewqr = crew["crew_qrcode"] as? string {         let imageurlstring = "http://52.221.231.3/gv/\(crewqr)"         let imageurl:url = url(string: imageurlstring)!         //print(imageurlstring)         dispatchqueue.global(qos: .userinitiated).async {              let imagedata:nsdata = nsdata(contentsof: imageurl)!              dispatchqueue.main.async {                 let image = uiimage(data: imagedata data)                 self.qrimg.image = image                 self.qrimg.contentmode = uiviewcontentmode.scaleaspectfit                 self.view.addsubview(self.qrimg)             }         }     } 

error: enter image description here

after edit

it seems full url of qr-code webservice don't append base address in imageurlstring crewqr url.

also, try safely unwrap optional (!)

let imagedata:nsdata = try? nsdata(contentsof: imageurl)  if let imagedata = imagedata {     let image = uiimage(data: imagedata) } 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -