You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to parse this JSON using the following swift code but failed:
let jsonData = NSData(contentsOfFile: NSBundle.mainBundle().pathForResource("provinces", ofType: "json")!)
if jsonData != nil {
let json = try? NSJSONSerialization.JSONObjectWithData(jsonData!, options:NSJSONReadingOptions.AllowFragments)
let array: Array<Dictionary<String, String>>? = json as? Array<Dictionary<String, String>>
if array != nil {
for dic in array! {
//never reaches here
}
} else {
//always reaches here
print("found nil array for province json")
}
Since the same code is working for other JSON files, I assume there is some syntax error with respect to Swift.
The text was updated successfully, but these errors were encountered:
I tried to parse this JSON using the following swift code but failed:
Since the same code is working for other JSON files, I assume there is some syntax error with respect to Swift.
The text was updated successfully, but these errors were encountered: