title: NSInvalidArgumentException: unrecognized selector sent to instance | SWIFT
body: <p>I realize this question has been asked many times, but it seems to be caused by many different things and is very situational. </p>
  
  <p>My trace:</p>
  
  <pre><code>2015-02-27 16:20:06.289 RTApp[43486:1122681] -[RTApp.conversationVC keyboardWasShown]: unrecognized selector sent to instance 0x7f866a766830
  2015-02-27 16:20:06.291 RTApp[43486:1122681] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RTApp.conversationVC keyboardWasShown]: unrecognized selector sent to instance 0x7f866a766830'
  *** First throw call stack:
  (
  0   CoreFoundation                      0x00000001071b8f35 __exceptionPreprocess + 165
  1   libobjc.A.dylib                     0x0000000106e51bb7 objc_exception_throw + 45
  2   CoreFoundation                      0x00000001071c004d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
  3   CoreFoundation                      0x000000010711827c ___forwarding___ + 988
  4   CoreFoundation                      0x0000000107117e18 _CF_forwarding_prep_0 + 120
  5   CoreFoundation                      0x0000000107188cec __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
  6   CoreFoundation                      0x00000001070888a4 _CFXNotificationPost + 2484
  7   Foundation                          0x00000001069af6b8 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
  8   UIKit                               0x0000000107c75eb8 -[UIInputWindowController postEndNotifications:withInfo:] + 527
  9   UIKit                               0x0000000107c77725 __77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke572 + 354
  10  UIKit                               0x0000000107617113 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 326
  11  UIKit                               0x00000001075fee6a -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 209
  12  UIKit                               0x00000001075ff1a0 -[UIViewAnimationState animationDidStop:finished:] + 76
  13  QuartzCore                          0x0000000105c4c7ee _ZN2CA5Layer23run_animation_callbacksEPv + 308
  14  libdispatch.dylib                   0x0000000108de57f4 _dispatch_client_callout + 8
  15  libdispatch.dylib                   0x0000000108dce8fb _dispatch_main_queue_callback_4CF + 949
  16  CoreFoundation                      0x0000000107120fe9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
  17  CoreFoundation                      0x00000001070e3eeb __CFRunLoopRun + 2043
  18  CoreFoundation                      0x00000001070e3486 CFRunLoopRunSpecific + 470
  19  GraphicsServices                    0x000000010aa0f9f0 GSEventRunModal + 161
  20  UIKit                               0x00000001075a5420 UIApplicationMain + 1282
  21  RTApp                               0x000000010563623e top_level_code + 78
  22  RTApp                               0x000000010563627a main + 42
  23  libdyld.dylib                       0x0000000108e1a145 start + 1
  )
  libc++abi.dylib: terminating with uncaught exception of type NSException
  </code></pre>
  
  <p>And the function in question:</p>
  
  <pre><code>func keyboardWasShown(notification: NSNotification){
  
      let dict:NSDictionary = notification.userInfo!
      let s:NSValue = dict.valueForKey(UIKeyboardFrameEndUserInfoKey) as NSValue
      let rect:CGRect = s.CGRectValue()
  
      UIView.animateWithDuration(0.3, delay: 0, options: .CurveLinear, animations: {
          self.resultsScrollView.frame.origin.y = self.scrollViewOriginalY - rect.height
          self.frameMessageView.frame.origin.y = self.frameMessageOriginalY - rect.height
  
          var bottomOffset:CGPoint = CGPointMake(0, self.resultsScrollView.contentSize.height - self.resultsScrollView.bounds.size.height)
          self.resultsScrollView.setContentOffset(bottomOffset, animated: false)
  
          }, completion: {
              (finished:Bool) in
      })
  }
  </code></pre>
  
  <p>So this should just be pushing the view up so it's not covered by the keyboard as you type. But as soon as I pull the keyboard up, it crashes. It would be great if Xcode told you what line the error is on, but that would be too easy..</p>
  
  <p>Does this mean the function doesn't recognizer the parameter I'm passing in to it? Or why can't it recognize the 'selector'?</p>