title: How to debug terminating with uncaught exception of type NSException
body: <p>I am running Swift 2 in Xcode 7. I have looked at a couple examples of people debugging this error after their app crashed but cannot figure how to debug this with my own app. Although I am not totally comfortable using them , after including some breakpoints, I think the error is in the top-middle of the code. Below is my code and any help would be great! I am a beginner so nothing too complicated please, thank you.</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
      func randomPoint() -&gt; CGPoint {
          let randomPoint: CGPoint = CGPoint(x:CGFloat(arc4random()%320),y:CGFloat(arc4random()%568))
          return randomPoint
      }
  
      func randomColor() -&gt; UIColor {
          let red = CGFloat(drand48())
          let green = CGFloat(drand48())
          let blue = CGFloat(drand48())
          return UIColor(red: red, green: green, blue: blue, alpha: 1.0)
      }
  
      func spawnEnemy() {
          let enemy: UIButton = UIButton(frame: CGRect(x: 160, y: 160, width: 50, height: 50))
          enemy.backgroundColor = randomColor()
          enemy.center = randomPoint()
          enemy.addTarget(self, action: Selector("buttonPushed:"), forControlEvents: UIControlEvents.TouchUpInside)
          self.view.addSubview(enemy)
      }
  
      func buttonPushed(sender : UIButton) {
          sender.backgroundColor = UIColor.whiteColor()
      }
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          NSTimer.scheduledTimerWithTimeInterval(0.5, target: self, selector: Selector("spawnEnemy:"), userInfo: nil, repeats: true)
  
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
  
      }
  
  }
  </code></pre>
  
  <p>The error I got was:</p>
  
  <pre><code>2016-02-12 08:31:47.665 app[84179:14802824] -[app.ViewController spawnEnemy:]: unrecognized selector sent to instance 0x7fc7c94474a0
  2016-02-12 08:31:47.687 app[84179:14802824] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[app.ViewController spawnEnemy:]: unrecognized selector sent to instance 0x7fc7c94474a0'
  *** First throw call stack:
  (
      0   CoreFoundation                      0x0000000107ed0e65 __exceptionPreprocess + 165
      1   libobjc.A.dylib                     0x0000000109c10deb objc_exception_throw + 48
      2   CoreFoundation                      0x0000000107ed948d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
      3   CoreFoundation                      0x0000000107e2690a ___forwarding___ + 970
      4   CoreFoundation                      0x0000000107e264b8 _CF_forwarding_prep_0 + 120
      5   Foundation                          0x00000001082b60d1 __NSFireTimer + 83
      6   CoreFoundation                      0x0000000107e30c84 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
      7   CoreFoundation                      0x0000000107e30831 __CFRunLoopDoTimer + 1089
      8   CoreFoundation                      0x0000000107df2241 __CFRunLoopRun + 1937
      9   CoreFoundation                      0x0000000107df1828 CFRunLoopRunSpecific + 488
      10  GraphicsServices                    0x000000010c4e3ad2 GSEventRunModal + 161
      11  UIKit                               0x00000001086ed610 UIApplicationMain + 171
      12  app                                 0x0000000107cf343d main + 109
      13  libdyld.dylib                       0x000000010a71992d start + 1
  )
  libc++abi.dylib: terminating with uncaught exception of type NSException
  </code></pre>