I have searched long, but couldn't find a solution for my bug. Swift somehow doesn't count my array (converted from json) correctly. This is the code I use to create the array:
let jsonData = NSData(contentsOfURL: url)
let jsonDic = NSJSONSerialization.JSONObjectWithData(jsonData, options: NSJSONReadingOptions.MutableContainers, error: &error) as NSDictionary
var count = jsonDic.count
When the count should be 3, the count is 2. So I just always added 1, but now if the count should be 4, the count is still 2.
Has anyone experienced something like that or is it just me doing something wrong?
EDIT: This is an example input:
{"items":[{"var1":"xxx","var2":"xxx","var3":"xxx","var4":"xxx","var5":0},{"var1":"xxx","var2":"xxx","var3":"xxx","var4":"xxx","var5":0}, {"var1":"xxx","var2":"xxx","var3":"xxx","var4":"xxx","var5":0}]}