我運行一個計時器,看起來像這樣:WKWebView.loading返回無法識別的選擇
else if label == "Instagram" && defaults.boolForKey("instagramswitch") {
activeWebview.loadRequest(request)
let dispatchTime: dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, Int64(1 * Double(NSEC_PER_SEC)))
dispatch_after(dispatchTime, dispatch_get_main_queue(), {
self.i = NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector: Selector("instagram:"), userInfo: activeWebview, repeats: true)
})
}
和功能如下:
func instagram(webview: WKWebView) {
if webview.loading == false {
let code: String = "document.getElementsByClassName('2yal _csflf').item(3).click();"
webview.evaluateJavaScript(code, completionHandler: nil)
let dispatchTime: dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, Int64(1 * Double(NSEC_PER_SEC)))
dispatch_after(dispatchTime, dispatch_get_main_queue(), {
self.i = NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector: Selector("instagramloaded:"), userInfo: webview, repeats: true)
})
}
}
我得到這一行的錯誤 - 「如果網頁視圖.loading ==假{」和錯誤是:
2016年4月10日15:16:53.679 PF 0.5 [878:241174] - [__ NSCFTimer isLoading]:無法識別的選擇發送到實例0x145a03fe0
任何和所有的幫助將不勝感激:)我認爲這是因爲我打電話給webview.loading,但我不知道爲什麼會導致崩潰。