Swift并将JSON解析为Dictionary - objectForKey

时间:2014-07-02 16:10:29

标签: json parsing swift

我有这个Objective C代码:

NSMutableArray *dataArray = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&error];

NSLog(@"Dictionary = %@",dataArray);

NSMutableArray *venues = [[NSMutableArray alloc] init];

for (NSDictionary *venueDic in dataArray) {
    MapPoint *mapPoint = [[MapPoint alloc] init];

    mapPoint.name = [venueDic objectForKey:@"name"];
    mapPoint.image_path = [venueDic objectForKey:@"image_path"];

    [venues addObject:mapPoint];

    NSLog(@"Venue Name: %@", mapPoint.name);

}

但我正在努力翻译FOR循环。我花了好几个小时都在寻找解决方案。

0 个答案:

没有答案