我有位于Xcode内部的json文件。我向UITableView显示信息,直到升级Xcode 7.你能告诉我如何解决这个问题吗?
以下是json文件的示例内容;
[
{
“title”: “School”,
“name”: [“Kyle”, “Joy”, “Melissa”],
},
{
“title”: “Job”,
“name”: [“Michael”, “Eric”, “Nichol”]
}
]
and here is how i could load data before upgrade Xcode;
lazy var stories : [AnyObject] = {
let path = NSBundle.mainBundle().pathForResource("Stories", ofType: "json")
let data = NSString(contentsOfFile: path!, encoding: NSUTF8StringEncoding, error: nil)
let result = data?.dataUsingEncoding(NSUTF8StringEncoding)
let json : [AnyObject]! = NSJSONSerialization.JSONObjectWithData(result!, options: NSJSONReadingOptions.MutableContainers, error: nil) as! [AnyObject]
return json
}()
答案 0 :(得分:0)
主要原因是由于NSAppTransportsecurity,因此您需要在xcode7中将以下内容添加到项目中。 在Info.plist中添加NSAppTransportSecurity As Dictionary& child as NSAllowsArbitraryLoads As Boolean值为YES