title: Why do I get fatal error: unexpectedly found nil while unwrapping an Optional value when trying to go to mapView?
body: <p>I'm working on an app Witch has a list of places (added by the user) and a map view with a button to add the users curent location. the app works to this point. When the user taps on a place in the tableView the app should go to the mapView and show the place on the map with a pin . but when I do that the app crashes and gives me the following error unless the user has renamed the place and if they have, it works perfectly :</p>
  
  <pre><code>fatal error: unexpectedly found nil while unwrapping an Optional value
  (lldb)
  </code></pre>
  
  <p>note that the crash occurs in the mapView on the line that says:</p>
  
  <pre><code>   let latitude = NSString(string: places[activePlace]["lat"]!).doubleValue
  </code></pre>
  
  <p>and that the </p>
  
  <pre><code>print("activePlace current value is \(activePlace)")
  </code></pre>
  
  <p>returns the number of the line in the TableView</p>
  
  <p>How could I solve this? thanks !</p>
  
  <p>Here is the code in the TableView:</p>
  
  <pre><code>import UIKit
  
  var places = [Dictionary&lt;String,String&gt;()]
  
  var activePlace = -1
  
  class TableViewController: UITableViewController {
  
      func companyNameUpdatedAlert(title: String, error: String, indexPath: Int) {
  
          let alert = UIAlertController(title: title, message: error, preferredStyle: UIAlertControllerStyle.Alert)
  
          alert.addTextFieldWithConfigurationHandler { (textField) -&gt; Void in
  
              textField.placeholder = "Enter new text"
  
          }
  
          alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: { (action) -&gt; Void in
  
              let lat = places[indexPath]["lat"]!
  
              let lon = places[indexPath]["lon"]!
  
              places.removeAtIndex(indexPath)
  
              places.insert(["name" : alert.textFields![0].text!, "lat" : lat, "lon" : lon], atIndex: indexPath)
  
              self.tableView.reloadData()
  
              NSUserDefaults.standardUserDefaults().setObject(places, forKey: "places")
              NSUserDefaults.standardUserDefaults().synchronize()
  
  
          }))
  
          self.presentViewController(alert, animated: true, completion: nil)
  
  
      }
  
      override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -&gt; [UITableViewRowAction]? {
  
          let changeText = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Change text" , handler: { (action:UITableViewRowAction, indexPath:NSIndexPath) -&gt; Void in
  
              self.companyNameUpdatedAlert("Update text", error: "enter text below", indexPath: indexPath.row)
  
          })
  
          let deleteAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Delete" , handler: { (action:UITableViewRowAction, indexPath:NSIndexPath) -&gt; Void in
  
              places.removeAtIndex(indexPath.row)
  
              tableView.reloadData()
  
              NSUserDefaults.standardUserDefaults().setObject(places, forKey: "places")
              NSUserDefaults.standardUserDefaults().synchronize()
  
          })
  
          return [changeText, deleteAction]
  
  
      }
  
      override func viewDidLoad() {
  
          //save start
  
          if NSUserDefaults.standardUserDefaults().objectForKey("places") != nil {
  
              places = NSUserDefaults.standardUserDefaults().objectForKey("places") as! [Dictionary]
  
              //test
  
  
              NSUserDefaults.standardUserDefaults().setObject(places, forKey: "places")
              NSUserDefaults.standardUserDefaults().synchronize()
  
  
  
              //save stop
  
          super.viewDidLoad()
  
  
  
          if places.count == 1 {
  
              places.removeAtIndex(0)
  
              places.append(["name":"go to map to add location","lat":"90","lon":"90"])
  
  
  
          }
          if NSUserDefaults.standardUserDefaults().objectForKey("places") != nil {
  
              places = NSUserDefaults.standardUserDefaults().objectForKey("places") as! [Dictionary]
  
  
          }
  
                  }
      }
  
      override func didReceiveMemoryWarning() {
  
          super.didReceiveMemoryWarning()
  
      }
  
      override func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
  
          return 1
  
      }
  
      override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
  
          return places.count
  
  
      }
  
      override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
          let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
  
          cell.textLabel?.text = places[indexPath.row]["name"]
  
          return cell
  
  
  
      }
  
      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
  
  
          }
  
      }
  
      override func viewWillAppear(animated: Bool) {
  
          tableView.reloadData()
  
  
      }
  
  }
  </code></pre>
  
  <p>and here is the code in the viewController ( mapView)</p>
  
  <pre><code>   if activePlace == -1 {
  
  
              manager.requestWhenInUseAuthorization()
              manager.startUpdatingLocation()
  
                  } else {
         print("activePlace current value is \(activePlace)")
  
  
          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)
  
          print("activePlaces current value is (activePlaces)")
  </code></pre>