I am working on my compatibility with IOS10 and I have a problem while executing this code:
if let results = NSJSONSerialization.TryJSONObjectWithData(data, options: []) as? NSDictionary {
print(" results : \(results)");
if let networkPosts = results["results"] as? NSMutableArray {
print(" here");
for i in 0 ..< networkPosts.count {
let post:Post = Post(postDictionary: networkPosts[i] as! NSDictionary, context: (UIApplication.sharedApplication().delegate as!
AppDelegate).coreDataHelper.managedObjectContext);
}
}
}
I see the results, so JSON is fine, but after I do not see the result in the dictionary. "Here" is never printed on my console. I try to make a breakpoint and it does not go there. I am also trying to use .objectForKey("key"), but the same result: /
Can anybody help me?
If i use results["results"] as? [[String: Any]]
Then
networkPosts [i] as! NSDictionary always fails
source
share