有人可以解释为什么我会根据其他代码的位置收到此错误吗?
为什么编译正常:
func serializeJSONData(jsonData: NSData) -> NSDictionary {
do {
let searchResultsJSON: NSDictionary = try NSJSONSerialization.JSONObjectWithData(jsonData, options: .MutableContainers) as! NSDictionary
return searchResultsJSON
} catch let error as NSError {
print("json error: \(error.localizedDescription)")
let returnDictionary = [:]
return returnDictionary
}
}
func parseForms(formsArray: NSArray) -> NSArray {
var retVal = [SearchFormObject]()
for form in formsArray as! NSDictionary { }
return retVal
}
当我像这样切换方法时:
func parseForms(formsArray: NSArray) -> NSArray {
var retVal = [SearchFormObject]()
for form in formsArray as! NSDictionary { }
return retVal
}
func serializeJSONData(jsonData: NSData) -> NSDictionary {
do {
let searchResultsJSON: NSDictionary = try NSJSONSerialization.JSONObjectWithData(jsonData, options: .MutableContainers) as! NSDictionary
return searchResultsJSON
} catch let error as NSError {
print("json error: \(error.localizedDescription)")
let returnDictionary = [:]
return returnDictionary
}
}
我在
上收到错误let searchResultsJSON: NSDictionary = try NSJSONSerialization.JSONObjectWithData(jsonData, options: .MutableContainers) as! NSDictionary
这是IDE还是我的代码中有实际错误?