I'm making an API REST application in Swift 2 with iOS 9, using SwiftyJSON support for Swift 2 (https://github.com/andrelind/SwiftyJSON). When I get my data and print it, I use this code:
RestApiManager.sharedInstance.getRandomUser { json in
let results = json["results"]
for (index: String, subJson: JSON) in results{
var user = subJson["user"].string
print(user)
}
}
With this code, I'm getting this error:
var user = subJson["user"].string
Use of unresolved identifier 'subJson error'
And According with Swift 2 documentation, a loop with dictionary is like:
for (key, value) in source{
//Do something
}
And SwiftyJSON documentation I can use it in this way:
for (key: String, subJson: JSON) in json {
//Do something you want
}
Anyone know why I receiving this error if in theory the declaration is correct. I'm using Xcode 7.0 beta 3, Swift 2 and my project if for iOS 9. Thanks!