Reputation: 1335
I followed the steps which were mentioned at the link of Google Maps SDK for iOS - Getting started . Following are the files that I created
AppDelegate.m
#import "AppDelegate.h"
#import "ViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
[GMSServices provideAPIKey:@"AIzaXXXXXXXXXXeGuCyxChdTECXXXXXXXXXXV9E"];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
//Other functions are there as it is.
ViewController.m
#import "ViewController.h"
#import <GoogleMaps/GoogleMaps.h>
@interface ViewController ()
@end
@implementation ViewController
{
GMSMapView *mapView_;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)loadView
{
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = mapView_;
}
@end
main.m
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool
{
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
//Error is displayed in the above line.
}
}
Following are the details of the error
2013-04-23 17:02:37.482 GMap[8146:12e03] +[GMSCameraPosition cameraWithLatitude:longitude:zoom:]: unrecognized selector sent to class 0x25ad5c
2013-04-23 17:02:37.483 GMap[8146:12e03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[GMSCameraPosition cameraWithLatitude:longitude:zoom:]: unrecognized selector sent to class 0x25ad5c'
*** First throw call stack:
(0x2418012 0x223de7e 0x24a32ad 0x2407bbc 0x240794e 0x2bb4 0x1262ff8 0x1263232 0x11b23d5 0x11b276f 0x11b2905 0x11bb917 0x27ad 0x117f157 0x117f747 0x118094b 0x1191cb5 0x1192beb 0x1184698 0x3133df9 0x3133ad0 0x238dbf5 0x238d962 0x23bebb6 0x23bdf44 0x23bde1b 0x118017a 0x1181ffc 0x24bd 0x23e5)
libc++abi.dylib: terminate called throwing an exception
Upvotes: 2
Views: 1703
Reputation: 5850
Your error is:
'+[GMSCameraPosition cameraWithLatitude:longitude:zoom:]: unrecognized selector sent to class 0x25ad5c'
According to the SDK that seems defined. How is that defined? If it's a category, you might need to link against the SDK with the flags -ObjC and -all_load.
Upvotes: 2