Swift NSURLConnection没有名为start的成员

戈汉·科克切西(GokhanCokkeçeci)
 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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Swift'没有名为的成员'

Swift ViewController没有名为的成员

Swift-桥接头失败。“ *”没有名为“ *”的成员

Swift-'String'没有名为'isEqualToString'的成员

Swift'WKInterfaceLabel'没有名为'text'的成员

'[细绳]?' 在Swift中没有名为“ count”的成员

Swift 1.2 [AnyObject]没有名为'objectForKey'的成员

Swift'String.Type'没有名为'stringWithContentsOfFile'的成员

Swift:'((NSObject,AnyObject)'没有名为'subscript'的成员

swift uiview没有名为center的成员

SWIFT字符串?没有名为“ element”的成员

“ NSURLRequest?” 没有名为“ URL”的成员-Swift

'UICollectionViewCell'没有名为'image'的成员[Swift]

模块“Swift”没有名为“Task”的成员

Swift数组“对象”没有名为下标的成员

Swift SpriteKit:“ MCTFruit没有名为append的成员吗?

Swift代码错误:String.Type没有名为'stringWithContentOfURL'的成员

$ T4没有名为Generator ERROR swift的成员

将变量声明为可选值时,Swift枚举没有名为“ rawValue”的成员

Swift 2.0'Element.Protocol'没有名为'Hour'的成员,NSCalendar.components

为什么AVPlayerView在Swift中没有名为“ player”的成员

Swift iOS8.1选择器没有名为'convertFromStringLiteral'的成员

没有名为的成员

“ UINavigationController?” 没有名为“ popToRootViewControllerAnimated”的成员

[AnyObject]?没有名为“下标”的成员

NSURLResponse没有名为allHeaderFields的成员

UIButton没有名为“ target”的成员

UIView没有名为'delegate的成员

UIView没有名为“ setTranslatesAutoresizingMaskIntoConstraints”的成员