【发布时间】:2015-10-12 18:04:15
【问题描述】:
所以在更新到 iOS 9 和 Swift 2 后,我的项目中出现了很多错误,即使单击自动转换选项也没有得到修复。幸运的是,大多数都很简单,我能够弄清楚它们,但我还剩下三个主要的。有人能帮我解决这些问题吗?
非常感谢!
代码块 #1
override func layoutAttributesForElementsInRect(rect: CGRect) -> [AnyObject]? {
return attributesList
}
块 1 出错
Method does not override any method from its superclass
代码块 #2
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
块 2 错误
A non-failable initializer cannot chain to failable initializer 'init(coder:)' written with 'init?'
代码块 #3
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) { (response: NSURLResponse!, data: NSData!, error: NSError!) -> Void in
块 3 错误
'(NSURLResponse!, NSData!, NSError!) -> Void' is not convertible to '(NSURLResponse?, NSData?, NSError?) -> Void'
编辑:现在第三个是固定的(但仍然不推荐使用)我在下面的代码中得到了这个错误:
代码:
var dictionary = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: nil) as! NSDictionary
错误:
Extra argument 'error' in call
【问题讨论】: