Swift:无法转换类型“ NSData!” 键入“ NSURLRequest!”

卑鄙的

我再次在Swift中遇到一个奇怪的错误。

Cannot convert the expression's type 'NSData!' to type 'NSURLRequest!'

我的代码是:

var request = NSURLRequest(URL: url, cachePolicy: NSURLRequestCachePolicy.ReloadIgnoringLocalCacheData, timeoutInterval: 5)

var response : NSURLResponse?
var error : NSError?

NSURLConnection.sendSynchronousRequest(request, returningResponse: response, error: error)
//The error is reported at the above line

那是什么意思?我无处尝试将NSData转换为NSURLRequest。

苏尔坦

我不确定为什么会显示这样的消息,但是您缺少&forinout参数。

NSURLConnection.sendSynchronousRequest(request, returningResponse: &response, error: &error)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章