NSURL返回零(Swift 2.0)

时间:2015-10-19 20:14:40

标签: xcode swift2 nsurl

为什么我为第二个让我变得零的任何想法?

if let url = NSURL (string: "https://domain.com/api/v2/oauth2/authorize?response_type=code&client_id=" + urlSuffix)
        {
            do
            {
                var file: String = " "

                try file = String(contentsOfURL: url, encoding: NSUTF8StringEncoding) as String

                print("Contents of page: \n" + file) //this works correctly and displays the contents, which is another URL)

                let uri = NSURL (string:file)
                print (uri) // this fails and returns nil

0 个答案:

没有答案