大佬教程收集整理的这篇文章主要介绍了IOS 10 objectForKey(“key”)的兼容性,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
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); } } }
我可以看到结果,所以JSON没问题,但是在我看不到字典的结果键之后.
“这里”永远不会打印在我的控制台上.我试着制作一个断点,同样它不会通过那里.
我也尝试使用.objectForKey(“key”)但结果相同:/
有谁可以帮助我吗 ?
如果我使用结果[“结果”]作为? [[String:Any]]
然后
使用Playground for Swift 3测试的示例:
let jsonString = "{\"name\":\"Mattia\",\"iosDevices\":[\"iPhone6\",\"iPad Air 2\",\"iPhone6+\"]} let jsonData = jsonString.data(using: String.Encoding.utf8,allowLossyConversion: false)! if let results = try JSONSerialization.jsonObject(with: jsonData,options: [.mutableContainers]) as? NSDictionary { print(" results : \(results)"); if let networkPosts = results["iosDevices"] as? NSMutableArray { print(" here"); } }
以上是大佬教程为你收集整理的IOS 10 objectForKey(“key”)的兼容性全部内容,希望文章能够帮你解决IOS 10 objectForKey(“key”)的兼容性所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。