title: [GADSlot state]: unrecognized selector sent to instance in iphone
body: <p>I am new to iOS development.</p>
  
  <p>I am trying to implementing admob ads in iOS in my phonegap app so I googled &amp; found somve<a href="http://therockncoder.blogspot.in/2012/05/cordova-phonegap-and-admob-together-ios.html" rel="nofollow noreferrer">admob without plugin</a>.</p>
  
  <p>after following all procedure,
  I got an error <strong>MyApp[2388:70b] *</strong> Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GADSlot state]: unrecognized selector sent to instance 0x10415920'**</p>
  
  <p>so I google about &amp; found that I have to change other Linker flags. <strong>(-ObjC)</strong><a href="https://stackoverflow.com/questions/12635283/admob-crashes-with-gadobjectprivate-changestate-unrecognized-selector">here</a></p>
  
  <p><strong>I have tried it but it is not working.</strong></p>
  
  <p><strong>I am getting this error.</strong></p>
  
  <p>this solution also not working for me. <a href="https://stackoverflow.com/questions/22837815/gadslot-state-unrecognized-selector-sent-to-instance">[GADSlot state]: unrecognized selector sent to instance</a></p>
  
  <pre><code>2014-04-21 13:04:41.252 MyApp[2388:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GADSlot state]: unrecognized selector sent to instance 0x10415920'
  *** First throw call stack:
  (
   0   CoreFoundation                      0x038a85e4 __exceptionPreprocess + 180
   1   libobjc.A.dylib                     0x02acb8b6 objc_exception_throw + 44
   2   CoreFoundation                      0x03945903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
   3   CoreFoundation                      0x0389890b ___forwarding___ + 1019
   4   CoreFoundation                      0x038984ee _CF_forwarding_prep_0 + 14
   5   MyApp                            0x0001a01e -[GADSlot isMakingRequest] + 36
   6   MyApp                            0x00019c7d -[GADSlot setAdType:andReloadRequest:] + 334
   7   MyApp                            0x00018a5e -[GADBannerView setAdSize:andReload:] + 512
   8   MyApp                            0x00019052 -[GADBannerView setAdSize:] + 62
   9   MyApp                            0x00019381 -[GADBannerView initWithAdSize:] + 171
   10  MyApp                            0x00003e17 -[MainViewController viewDidLoad] + 118
   11  UIKit                               0x0021c318 -[UIViewController loadViewIfRequired] + 696
   12  UIKit                               0x0021c5b4 -[UIViewController view] + 35
   13  MyApp                            0x00002997 -[AppDelegate application:didFinishLaunchingWithOptions:] + 763
   14  UIKit                               0x00102355 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
   15  UIKit                               0x00102b95 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1536
   16  UIKit                               0x001073a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
   17  UIKit                               0x0011b87c -[UIApplication handleEvent:withNewEvent:] + 3447
   18  UIKit                               0x0011bde9 -[UIApplication sendEvent:] + 85
   19  UIKit                               0x00109025 _UIApplicationHandleEvent + 736
   20  GraphicsServices                    0x038062f6 _PurpleEventCallback + 776
   21  GraphicsServices                    0x03805e01 PurpleEventCallback + 46
   22  CoreFoundation                      0x03823d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
   23  CoreFoundation                      0x03823a9b __CFRunLoopDoSource1 + 523
   24  CoreFoundation                      0x0384e77c __CFRunLoopRun + 2156
   25  CoreFoundation                      0x0384dac3 CFRunLoopRunSpecific + 467
   26  CoreFoundation                      0x0384d8db CFRunLoopRunInMode + 123
   27  UIKit                               0x00106add -[UIApplication _run] + 840
   28  UIKit                               0x00108d3b UIApplicationMain + 1225
   29  MyApp                            0x000025fd main + 95
   30  MyApp                            0x00002595 start + 53
   )
  libc++abi.dylib: terminating with uncaught exception of type NSException
  </code></pre>
  
  <p>please help me out.</p>
  
  <p><strong>main.m</strong></p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  int main(int argc, char *argv[]) {
  
      NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
      int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");//It highlight this line when exception accoure.
      [pool release];
      return retVal;
  }
  </code></pre>
  
  <p><strong>MainViewController.m</strong></p>
  
  <pre><code>- (void) viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view from its nib.
      bannerView_ = [[GADBannerView alloc]initWithAdSize:kGADAdSizeSmartBannerPortrait];
  
      CGRect screenRect = [[UIScreen mainScreen] bounds];
      CGFloat screenWidth = screenRect.size.width;
      CGFloat screenHeight = screenRect.size.height;
      CGFloat screenXPos = (screenWidth/2);
      CGFloat screenYPos = screenHeight - kGADAdSizeBanner.size.height;
      [bannerView_ setCenter:CGPointMake(screenXPos, screenYPos)];
      bannerView_.adUnitID = MY_BANNER_UNIT_ID;
      bannerView_.rootViewController = self;
      [self.view addSubview:bannerView_];
      GADRequest *request = [GADRequest request];
      request.testing = NO;
      [bannerView_ loadRequest:request];
  
  }
  </code></pre>