title: Why am I getting "EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)"
body: <p>I am getting </p>
  
  <blockquote>
    <p>"EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)"</p>
  </blockquote>
  
  <p>in this code</p>
  
  <pre><code>else {
      let latitude = NSString(string: places[activePlace]["lat"]!).doubleValue
      let longitude = NSString(string: places[activePlace]["lon"]!).doubleValue
      let coordinate = CLLocationCoordinate2DMake(latitude, longitude)
      let latDelta:CLLocationDegrees = 0.01
      let lonDelta:CLLocationDegrees = 0.01
      let span:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, lonDelta)
      let region:MKCoordinateRegion = MKCoordinateRegionMake(coordinate, span)
      self.Map.setRegion(region, animated: true)
      let annotation = MKPointAnnotation()
      annotation.coordinate = coordinate
  
      annotation.title = places[activePlace]["name"]
      self.Map.addAnnotation(annotation)
  </code></pre>
  
  <p>on </p>
  
  <pre><code> let latitude = NSString(string: places[activePlace]["lat"]!).doubleValue
  </code></pre>
  
  <p>here is my active place variable witch is in a previous table view </p>
  
  <p>var activePlace = -1]</p>
  
  <p>still in the tableview I have this</p>
  
  <pre><code> override func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -&gt; NSIndexPath? {
  
          activePlace = indexPath.row
  
          return indexPath
  
      }
  
      override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
  
          if segue.identifier == "newPlace" {
  
              activePlace = -1
  
  
          }
  </code></pre>
  
  <p>in the second view controller ( where I have the problem )
  I have this in the view did load</p>
  
  <pre><code>manager = CLLocationManager()
  manager.delegate = self
  manager.desiredAccuracy = kCLLocationAccuracyBest
  
  if activePlace == -1 {
  
      manager.requestWhenInUseAuthorization()
      manager.startUpdatingLocation()
  
  
  } else {
  
  
  
      let latitude = NSString(string: places[activePlace]["lat"]!).doubleValue
  
      let longitude = NSString(string: places[activePlace]["lon"]!).doubleValue
  
      let coordinate = CLLocationCoordinate2DMake(latitude, longitude)
  
      let latDelta:CLLocationDegrees = 0.01
  
      let lonDelta:CLLocationDegrees = 0.01
  
      let span:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, lonDelta)
  
      let region:MKCoordinateRegion = MKCoordinateRegionMake(coordinate, span)
  
      self.Map.setRegion(region, animated: true)
  
      let annotation = MKPointAnnotation()
  
      annotation.coordinate = coordinate
  
  
      annotation.title = places[activePlace]["name"]
  
      self.Map.addAnnotation(annotation)
  </code></pre>
  
  <p>This code was already there and worked perfect until I added the following code</p>
  
  <pre><code>@IBAction func addCurentLoc(sender: UIBarButtonItem) {
  
          var newCoordinate2 = self.Map.userLocation.location!.coordinate;
  
          var location = CLLocation(latitude: newCoordinate2.latitude, longitude: newCoordinate2.longitude)
  
          title = "new address"
  
  
          let annotation = MKPointAnnotation();
          annotation.title = title;
          annotation.coordinate = self.Map.userLocation.location!.coordinate;
  
          CLGeocoder().reverseGeocodeLocation(location) { (placemarks, error) -&gt; Void in
  
              var title = ""
  
              if (error == nil) {
  
                  if let p = placemarks?[0] {
  
                      var subThouroughfare:String = ""
                      var thouroughfare:String = ""
  
                      if p.subThoroughfare != nil {
  
                          subThouroughfare = p.subThoroughfare!
  
                      }
  
                      if p.thoroughfare != nil {
  
                          thouroughfare = p.thoroughfare!
  
                      }
  
                      title = "\(subThouroughfare) \(thouroughfare)"
  
  
                  }
  
              }
  
              if title == "" {
  
                  title = "Added \(NSDate())"
  
              }
  
              places.append(["name":title,"lat":"\(newCoordinate2.latitude)","lon":"\(newCoordinate2.longitude)"])
  
              let annotation = MKPointAnnotation()
  
              annotation.coordinate = newCoordinate2
  
              annotation.title = title
  
              self.Map.addAnnotation(annotation)
  
          }
  
          self.Map.addAnnotation(annotation);
  
  
  
          func mapView(mapView: MKMapView!,
              viewForAnnotation annotation: MKAnnotation!) -&gt; MKAnnotationView!{
                  if(annotation is MKUserLocation){
                      return nil;
                  }
  
                  let pinView: Void = mapView.addAnnotation(annotation);
                  let pinAnnotationView = MKPinAnnotationView(annotation: annotation,reuseIdentifier:"MyIdentifier");
                  return pinAnnotationView;
  
                         }
  
  
  
      }
  </code></pre>
  
  <p>I have been looking for an a solution for a while and can't find out, note that I have checked this answer</p>
  
  <p><a href="https://stackoverflow.com/questions/24337791/exc-bad-instruction-code-exc-i386-invop-subcode-0x0-on-dispatch-semaphore-dis">EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) on dispatch_semaphore_dispose</a></p>
  
  <p>as well as this one</p>
  
  <p><a href="https://stackoverflow.com/questions/28804654/what-does-error-thread-1exc-bad-instruction-code-exc-i386-invop-subcode-0x0">what does Error &quot;Thread 1:EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)&quot; mean?</a></p>
  
  <p>but haven't found the solution, thanks for the help</p>
  
  <p>EDIT: Please note that this question has been modified to be a bit clearer, please ask if you need more info.</p>