2015-09-16 16 views
1

因爲我在我的UIWebView使用cachePolicy我得到這個錯誤:用的CachePolicy得到錯誤

0x196a994c8 <+28>: ldr x9, [x19] WebThread (6): EXC_BAD_ACCESS (code =1, address=0x8)

如果我先打開,而不在代碼中的CachePolicy的觀點,後來編輯的代碼具有的CachePolicy並重新構建它,它確實有效。

但是,如果我直接使用cachePolicy啓動視圖,該視圖在未啓動該視圖之前無法啓動該視圖。

這是我的代碼(給)中的錯誤:

var url = NSURL(string: "http://visia-ontwikkeling.nl/polen/pages.php?page=information_point") 
let requestObj = NSURLRequest(URL: url!, cachePolicy: NSURLRequestCachePolicy.ReturnCacheDataDontLoad, timeoutInterval: 5); 
webViewLabel.loadRequest(requestObj); 

,這是它如何工作,但沒有緩存:

var url = NSURL(string: "http://visia-ontwikkeling.nl/polen/pages.php?page=information_point") 
let requestObj = NSURLRequest(URL: url!); 
webViewLabel.loadRequest(requestObj); 

enter image description here

回答

3

我建議你檢查NSUrlCache。我認爲你的緩存策略是錯誤的。即使它不存在,您也可以強制請求獲取緩存數據。您應該使用NSURLRequestReturnCacheDataElseLoad。如:

var url = NSURL(string: "http://visia-ontwikkeling.nl/polen/pages.php?page=information_point") 
let requestObj = NSURLRequest(URL: url!, cachePolicy: NSURLRequestCachePolicy. ReturnCacheDataElseLoad, timeoutInterval: 5) 
webViewLabel.loadRequest(requestObj) 
+0

非常感謝您的工作! –

+0

你可以接受答案,如果它的工作。 – ridvankucuk