【发布时间】:2014-11-04 21:26:51
【问题描述】:
Value of optional type 'NSURL?' not unwrapped; did you mean to use '!' or '?'?
当我输入 "!" 或 "?" 时,我的应用无法构建。
这段代码在小牛队中工作,但自从我更新到 Yosemite 后,我得到了一个错误。
我相信这是一个语法错误,但我找不到解决方案。
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
var url = NSURL(string: "http://www.stackoverflow.com")
let task = NSURLSession.sharedSession().dataTaskWithURL(url) {(data, response, error) in
println(NSString(data: data, encoding:NSUTF8StringEncoding))
}
【问题讨论】:
标签: ios xcode url swift osx-yosemite