I have code that loads a map view and places a marker on it. I have basically refactored my code to be Google sample code for adding a GMSMarker. The app runs no problem in the simulator (8.4), but when the marker code is added to the map on my iPhone 6 (marker.map = mapView_
), the app crashes and I get the error in Xcode: EXC_BAD_ACCESS (code=1, address=0x0).
The mapView loads fine on the phone when I remove the marker.map = mapView_
line of code. Here is the what I have reduced my code to in viewDidLoad: below.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithTarget:loc zoom:12.5];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.settings.myLocationButton = YES;
mapView_.settings.tiltGestures = NO;
mapView_.settings.rotateGestures = NO;
mapView_.delegate = self;
dispatch_async(dispatch_get_main_queue(), ^{
mapView_.myLocationEnabled = YES;
});
self.view = mapView_;
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = camera.target;
marker.snippet = @"Hello World";
marker.appearAnimation = kGMSMarkerAnimationPop;
marker.map = mapView_;