Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
889 views
in Technique[技术] by (71.8m points)

error unrecognized selector sent to class while adding Google Map SDK to iOS6

This is a single view application and I followed the instruction given at link https://developers.google.com/maps/documentation/ios/start for adding google map SDK to iOS6. ERROR Is:

unrecognized selector sent to class 0xe2b0
2013-02-07 15:21:29.788 mapApp[2061:12e03] *** Terminating app due to uncaught exception     
'NSInvalidArgumentException', reason: '+[GMSCameraPosition    
cameraWithLatitude:longitude:zoom:]: unrecognized selector sent to class 0xe2b0'

AppDelegate.m

- (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];
    self.window.rootViewController = self.viewController;

   //initializing google map api key
   [GMSServices provideAPIKey:@"google's api key goes here"];

   [self.window makeKeyAndVisible];
   return YES;

}

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.

   GMSCameraPosition *cam = [GMSCameraPosition cameraWithLatitude:13.0245231 
                                                        longitude:77.64072579999993                
                                                             zoom:6];

   mapView = [GMSMapView mapWithFrame:CGRectZero camera:cam];
   mapView.myLocationEnabled = YES;

   GMSMarkerOptions *options = [[GMSMarkerOptions alloc]init ];
   options.position = CLLocationCoordinate2DMake(13.025738,77.637809);
   options.title = @"ensign";
   options.snippet = @"kalyan nagar";

   [mapView addMarkerWithOptions:options];

}

main.m

#import <UIKit/UIKit.h>
#import <GoogleMaps/GoogleMaps.h>
int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv,nil, NSStringFromClass([AppDelegate class]));
    }
}

While tracking the error it is showing at the return statement in main.m which comes from the method -viewDidLoad after executing the first line

GMSCameraPosition *cam = [GMSCameraPosition cameraWithLatitude:13.0245231 
                                                    longitude:77.64072579999993                
                                                         zoom:6];

It escapes the rest of the lines.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Did you add -ObjC to the Other Linker Flags, in step 7 of the instructions?

-- Extra information edit: note that -ObjC is case sensitive.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...