File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
WKWebViewJavascriptBridgeDemo Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ class ViewController: UIViewController {
4040 bridge = WKWebViewJavascriptBridge ( webView: webView)
4141 bridge. register ( handlerName: " testiOSCallback " ) { ( paramters, callback) in
4242 print ( " testiOSCallback called: \( String ( describing: paramters) ) " )
43- callback! ( " Response from testiOSCallback " )
43+ callback ? ( " Response from testiOSCallback " )
4444 }
4545 bridge. call ( handlerName: " testJavascriptHandler " , data: [ " foo " : " before ready " ] , callback: nil )
4646 }
@@ -56,12 +56,11 @@ class ViewController: UIViewController {
5656 }
5757
5858 do {
59- let pagePath = Bundle . main. path ( forResource: " Demo " , ofType: " html " )
60- guard pagePath != nil else {
59+ guard let pagePath = Bundle . main. path ( forResource: " Demo " , ofType: " html " ) else {
6160 throw LoadDemoPageError . nilPath
6261 }
63- let pageHtml = try String ( contentsOfFile: pagePath! , encoding: . utf8)
64- let baseURL = URL ( fileURLWithPath: pagePath! )
62+ let pageHtml = try String ( contentsOfFile: pagePath, encoding: . utf8)
63+ let baseURL = URL ( fileURLWithPath: pagePath)
6564 webView. loadHTMLString ( pageHtml, baseURL: baseURL)
6665 } catch LoadDemoPageError . nilPath {
6766 print ( print ( " webView loadDemoPage error: pagePath is nil " ) )
You can’t perform that action at this time.
0 commit comments