Filip Bellander - 1 year ago 38

iOS Question

I am trying to print locations for each row in IndexPath.row because the IndexPath.row determine which specific content they want to receive in the TableView.

The NSDictionary from Firebase looks like:

`x,y,x,y,x,y`

0,1 = first coordinates

2,3 = second coordinates

`Output: [55.617804300000003, 12.98939, 55.601572900000001, 12.979585399999999, 34.506667999999998, -81.948334000000003, -7.0909109999999993, 107.668887]`

So first 0 and 1 is x, y for first coordinates with following:

`print(CLLocationCoordinate2D(latitude: openLocations[indexPath.row], longitude: openLocations[indexPath.row + 1]))`

How our results is at the moment:

`x= longitude, y = altitude`

x, y

0, 1

1, 2

2, 3

3, 4

5, 6

How it should be:

`x= longitude, y = altitude`

x, y

0, 1

2, 3

4, 5

6, 7

8, 9

NSDictonary looks like:

x,y,x,y,x,y ..

This should be an easy task but my mind at the moment is somewhere else, if any could help me straight this out, it would be highly appreciated.

Thanks In Advance,

Sincerely yours,

Filip

Answer

You have to take every second row:

```
latitude: openLocations[2 * indexPath.row], longitude: openLocations[2 * indexPath.row + 1]
```

Source (Stackoverflow)