var connection = NSURLConnection(request: theRequest, delegate: self, startImmediately: true)
connection.start()
错误:NSURLConnection没有名为start的成员
任何的想法 ?为什么开始不能在这里工作:(
正如其他张贴者所指出的那样,由于您true
以as传递startImmediately
,因此实际上不需要调用start
,但这并不能解释为什么找不到它。
var connection = NSURLConnection(request: theRequest, delegate: self, startImmediately: true)
返回一个可选(请求可能无法通过处理NSURLConnection
),因此您必须将其解包,其中任何一种:
connection!.start()
connection?.start()
if let connection = connection {
connection.start()
}
else {
// handle error case
}
会以您的偏好/安全性从高到低的顺序为您服务。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句