Reputation: 47
I'm new to Objective-C and I'm working with Google Maps SDK for iOS. I want to see NSLog output when a marker is clicked. I used following delegate method of GMSMapViewDelegate:
Here is the my code. What do you think is missing?
#import "testViewController.h"
@interface testViewController ()
@end
@implementation testViewController{
GMSMapView *mapView_;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
mapView_.delegate = self;
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:41.12
longitude:29.05
zoom:12];
mapView_ = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(41.12, 29.05);
marker.title = @"burdayım";
marker.map = mapView_;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(GMSMarker *)marker {
NSLog(@"ssssss");
}
- (void)dealloc {
[_V_map release];
[super dealloc];
}
@end
Upvotes: 0
Views: 1751
Reputation: 11537
You are setting mapView_.delegate = self
; before mapView_ = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
mapView_ will be nil when you set the delegate; set the delegate after the instanciation so your instance variable is not nil.
Upvotes: 3