I\'m newbie in iOS dev and I\'m trying to parse a local Json file such as
{\"quizz\":[{\"id\":\"1\",\"Q1\":\"When Mickey was born\",\"R1\":\"1920\",\"R2\":\"1
Swift 2.3 I use a utility method to convert JSON files to a Dictionary:
func getDictionaryFromJSON(jsonFileName: String) -> [String: AnyObject]? {
guard let filepath = NSBundle.mainBundle().pathForResource(jsonFileName, ofType: "json") else {
return nil
}
guard let data = NSData(contentsOfFile: filepath) else {
return nil
}
do {
let dict = try NSJSONSerialization.JSONObjectWithData(data, options: []) as? [String: AnyObject]
return dict
} catch {
print(error)
return nil
}
}