从mac OS 10.12.1&中获取网站价值iOS 10.1.1

时间:2016-11-08 11:58:54

标签: ios xcode https

自最新更新以来获得错误。 无法从https网站返回数据。

请帮忙

代码:

func GetValueFromWebsite(_ Url: String, ShowError: Bool) -> String {
    var xml:String = ""
    let url = URL(string: Url)
    let request = NSMutableURLRequest(url: url!)
    let session = URLSession.shared
    session.sendSynchronousRequest(request: request) { data, response, error in
        xml = String(data: data! as Data, encoding: String.Encoding.utf8)!
        xml = xml.replacingOccurrences(of: "\"", with: "")
        xml = xml.replacingOccurrences(of: "\r\n", with: "")
    }
return xml
}

0 个答案:

没有答案