i'm beginner @ swift on stack overflow. first things first, have researched question online , went through related questions.the answer hoping vague (swift - exc_bad_instruction (code=exc_i386_invop, subcode=0x0) datataskwithurl) , hoping clearer answer. trying use webview display url, , keep on getting error 'thread 1: exc_bad_instruction (code=exc_i386_invop, subcode=0x0)' , 'fatal error: unexpectedly found nil while unwrapping optional value'. please me? thank you!
here code:
import uikit class viewcontroller: uiviewcontroller { @iboutlet var moongatewebview: uiwebview! @iboutlet var managebacwebview: uiwebview! @iboutlet var moodlewebview: uiwebview! @iboutlet var librarywebview: uiwebview! @iboutlet var ccawebview: uiwebview! @iboutlet var gmailwebview: uiwebview! override func viewdidload() { super.viewdidload() //loading moongate on screen let mgurl = nsurl(string: "http://moongate.cis.edu.hk/") let mgrequest = nsurlrequest(url: mgurl!) moongatewebview.loadrequest(mgrequest) //error occurs //loading managebac on screen let mburl = nsurl(string:"https://cishk.managebac.com/login" ) let mbrequest = nsurlrequest(url: mburl!) managebacwebview.loadrequest(mbrequest) //loading moodle on screen let mdurl = nsurl(string: "http://moodle.cis.edu.hk/moodle/") let mdrequest = nsurlrequest(url: mdurl!) moodlewebview.loadrequest(mdrequest) //loading library on screen let liburl = nsurl(string: "http://library.cis.edu.hk/") let librequest = nsurlrequest(url: liburl!) librarywebview.loadrequest(librequest) //loading ccas on screen let ccaurl = nsurl(string: "http://moongate.cis.edu.hk/content/page.aspx?e=f17a69b3-62f1-46ff-a474-8776c2d2492d") let ccarequest = nsurlrequest(url: ccaurl!) ccawebview.loadrequest(ccarequest) //loading gmail on screen let gmailurl = nsurl(string: "https://mail.google.com/mail/u/0/") let gmailrequest = nsurlrequest(url: gmailurl!) gmailwebview.loadrequest(gmailrequest) } }
possible problem webview may nil.
to check this, need use assistant editor
(where can see split view) show storyboard on 1 side , code on other.
in way can check @iboutlet
correctly bound. positioning mouse on ribbon left of each of web views, highlight element bound:
if variable not bound, can see empty circle instead full circle.
you first check that, sure elements correctly bound.
Comments
Post a Comment