ios - EXC_BAD_INSTRUCTION in Swift when loading a WebView -


i followed tutorial make web view on ios app , don't errors. however, when build app test on simulator, error:

exc_bad_instruction (code=exc_i386_invop, subcode=0x0)

here viewcontroller.swift

import uikit  class viewcontroller: uiviewcontroller {     @iboutlet var webview : uiwebview!     var urlpath = "http://google.com"      override func viewdidload() {         super.viewdidload()         loadaddressurl()     }      override func didreceivememorywarning() {         super.didreceivememorywarning()         // dispose of resources can recreated.     }      func loadaddressurl(){         let requesturl = nsurl(string:urlpath)         let request = nsurlrequest(url:requesturl!)         webview.loadrequest(request)     } } 

when run app webview.loadrequest(request) marked in red , displays error. in debugger "fatal error: unexpectedly found nil while unwrapping optional value"

you sure made mistake in connection uiwebview storyboard/xib code. should remove existed connection in storyboard/xib, delete line

@iboutlet var webview : uiwebview! 

and connect again. proper declaration should contain word weak in order:

@iboutlet weak var webview : uiwebview! 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -