swift uiwebview NSErrorFailingURLStringKey

Posted

技术标签:

【中文标题】swift uiwebview NSErrorFailingURLStringKey【英文标题】: 【发布时间】:2016-12-12 11:35:28 【问题描述】:

如何为 UIWebView 的 didFailLoadWithError 快速打印 NSErrorFailingURLStringKey 的值?

我有localizedDescriptionNSError 的其他选项,但正在寻找NSErrorFailingURLStringKey 字符串。

这可能吗?请帮忙。

提前致谢。

【问题讨论】:

【参考方案1】:

首先,你的问题没有说清楚。

var res = (task.response as! HTTPURLResponse)
print(" status code ->\(Int((res as! HTTPURLResponse).statusCode))")
do 
    if res.statusCode == 440 
        // handel error here.
    
    else if res.statusCode == 308 
        // handel error here.
    
    else if res.statusCode == 400 || res.statusCode == 500 
        var dictFromData = try JSONSerialization.jsonObject(withData: error.userInfo![AFNetworkingOperationFailingURLResponseDataErrorKey], options: NSJSONReadingAllowFragments)!
        // handel error here.
    
    else 
        // handel error here.
    


catch 

【讨论】:

以上是关于swift uiwebview NSErrorFailingURLStringKey的主要内容,如果未能解决你的问题,请参考以下文章