美文网首页
iOS Swift3.0 获取重定向之后的url

iOS Swift3.0 获取重定向之后的url

作者: 梁同桌 | 来源:发表于2017-01-16 13:27 被阅读155次
let req = URLRequest(url: URL(string: "http://cn-gdfs16-dx.acgvideo.com/vg19/8/8f/13083625-1-hd.mp4?expires=1484548200&ssig=SleYiSWduQ5N8YF00vZXEQ&oi=1917006008&nfa=zewukGbkdeYAV6tVxJRokA==&dynamic=1")!)
        
let connection = NSURLConnection(request: req, delegate: self)
connection?.start()


//代理方法:NSURLConnectionDataDelegate
    func connection(_ connection: NSURLConnection, willSend request: URLRequest, redirectResponse response: URLResponse?) -> URLRequest? {
        print(request.url!)//这里打印重定向之后的地址
        return request
    }

相关文章

网友评论

      本文标题:iOS Swift3.0 获取重定向之后的url

      本文链接:https://www.haomeiwen.com/subject/psfpbttx.html