- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
此代码完全适用于我之前在 iOS 8 和 swift 2.0 上的项目。
这是我的代码:
let url=NSURL(string: _resourceURL)!
Alamofire.request(.GET ,url).responseJSON { (request : NSURLRequest?,response: NSHTTPURLResponse?, result: Result<AnyObject> ) -> void in
print(result.value.debugDescription)
}
现在我尝试使用 iOS 9、Swift 3.0、alamofire 4.0.0但抛出以下错误:
Generic type 'Result' specialized with too few type parameters (got 1, but expected 2)
Use of undeclared type 'void'
Contextual closure type 'Response -> Void' expects 1 argument, but 3 were used in closure body
最佳答案
如果您没有需要转换 JSON 的特定对象,并且您乐于通过键访问属性,您可以这样做:
Alamofire.request(.GET, url).responseJSON { response in
if let JSON = response.result.value {
print("JSON: \(JSON)")
}
}
关于ios - 上下文闭包类型 Response<AnyObject> -> void 需要 1 个 agrument 但 3 个在闭包体中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39445831/
我正在尝试使用执行文本解释器的 execl 函数打印命令行参数,但我无法打印第一个参数。 这是我的主程序 #include #include #include #inc
让我们编写一个将数字作为输入的程序。尽管如此,可以指定基数。未指定时,数字以十进制为基数。 # 10 in decimal ./get_num.py 10 # 10 in octal ./get_nu
我在使用/usr/bin/env 时遇到了一个奇怪的问题...我设计了一个简单的脚本来显示这个问题。该脚本是用 Ruby 编写的,但同样的情况也发生在 Python 中的类似脚本中。这是脚本: #!/
当 spline = UnivariateSpline(x, y, bbox=[0,1], k=3.0,s=0.0) 对比 spline = UnivariateSpline(x, y, k=3.0,
此代码完全适用于我之前在 iOS 8 和 swift 2.0 上的项目。 这是我的代码: let url=NSURL(string: _resourceURL)! Alamofire.request(
我是一名优秀的程序员,十分优秀!