I've searched a lot but I can't find what I'm doing wrong. I'm trying to get 2 numbers that are stored in Firebase (uses a json file) and then create google maps markers with one of these numbers being the latitude and the other the longitude.
__block int i =0;
while (i < 5) {
i++;
NSString *url = [NSString stringWithFormat:@"---myfirebaseurl---", i];
Firebase *ref = [[Firebase alloc] initWithUrl:url];
[ref observeEventType:FEventTypeChildAdded withBlock:^(FDataSnapshot *snapshot) {
if (snapshot.value == [NSNull null]){
i = 5;
}
if (snapshot.value != [NSNull null]){
NSString *latitudestring = snapshot.value[@"latitude"];
NSString *longitudestring = snapshot.value[@"longitude"];
long latitude = [latitudestring longLongValue];
long longitude = [longitudestring longLongValue];
NSLog(@"latitude: %li and longitude: %li", latitude, longitude);
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(latitude, longitude);
GMSMarker *marker = [GMSMarker markerWithPosition:position];
marker.map = mapview;
marker.title = (@"%@", snapshot.value[@"nome"]);
marker.snippet = (@"%@", snapshot.value[@"endereco"]);
}
}
];
}
Sorry if the code it's kinda messy.
This error message appears: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString objectForKeyedSubscript:]
And the google maps markers aren't created at all. Any insight on this?