I have some difficult to convert my Swift 2.2 app to Swift 3.0.
I have some errors and I don't find the solution yet. Currently, my worst problem is with NSFastEnumerationIteration
, I try to get records from JSON but with this error I can't. This is the screenshot of my code with the problem :
NSFastEnumerationIteration.member Swift 3
114 Views Asked by ewan At
2
There are 2 best solutions below
0

For in loop only knows that your variable data is an array and doesn't know anything else, so you need to provide as well the type of the content of your variable data:
let dataToParse = dataweneed.data(using: String.Encoding.utf8.rawValue)!
let jsonOptions = [JSONSerialization.ReadingOptions.mutableContainers]
let data = try JSONSerialization.jsonObject(with: dataToParse, options: jsonOptions)
// now For in loop would know that you
// could have an array of dictionaries
if let data = data as? [[String: Any]] {
for dd in data {
// your code
}
}
In Swift 3 you need to specify the type of object,so specify the type of your data Array to
[[String:Any]]
.