Pin an annotation to mapView with the saved coordinates in CoreData

I have searched now all over the internet and I have tried almost everything. My current project is:

I read the current coordinates from the User Location and save the latitude and longitude in CoreData and the name of this place(user can give a name)

  • send email from swift osx application
  • How to remove node from parent if touched more than once?
  • Return instancetype in Swift
  • Convert Date String to Int Swift
  • Find first element matching condition in Swift array (e.g. EKSource)
  • Obtain NSURL from UIImagePickerController
  •  // MARK: - AddPlace Button Events
    @IBAction func onAddButton(sender: AnyObject) {
            //searching the current location
            let locCoord = CLLocationCoordinate2DMake(self.locationManager.location!.coordinate.latitude, self.locationManager.location!.coordinate.longitude)
            // 1. pass the data from the current location to lat and lng
            let lat = locCoord.latitude
            let lng = locCoord.longitude
            let ed = NSEntityDescription.entityForName("Store", inManagedObjectContext: moContext)
            let store = Store(entity: ed!, insertIntoManagedObjectContext: moContext)
            // 2. give the passed data to the array from CoreData
            store.storeName = noteTextField.text
            store.storeLng = lng
            store.storeLat = lat
            do  {
                // 3. save the informations in CoreData
                noteTextField.text  = ""
                // 4. testing if the coordinates are saved - it works!

    Now my problem is to display a pin on the saved place in another ViewController with a mapView. I tried:


    storeLat –> stored as Double

    storeLng –> stored as Double

    storeName –> stored as String

    //MARK: - Second ViewController with a mapView
        override func viewDidLoad() {
        // Initialize Fetch Request
        let fetchRequest = NSFetchRequest()
        // Create Entity Description
        let entityDescription = NSEntityDescription.entityForName("Store", inManagedObjectContext: self.moContext)
        // Configure Fetch Request
        fetchRequest.entity = entityDescription
        do {
            stores = try moContext.executeFetchRequest(fetchRequest) as! [Store]
            if stores.count > 0
                // add the annotation
                let annotation = MKPointAnnotation()
                annotation.coordinate = CLLocationCoordinate2D(latitude: store!.storeLat as! Double, longitude: store!.storeLng as! Double)
                annotation.title = store?.storeName
            } else
                let alert = SCLAlertView()
                alert.showError("Keine Places", subTitle: "Du hast noch keine Places gespeichert.")
        } catch {
            fatalError("Failed to fetch Places: \(error)")

    Now it’s going into the if – Statement. But I get a failure when I want to place the annotation. fatal error: unexpectedly found nil while unwrapping an Optional value. I think I have forget something to declare. Can someone help? Thank you already!

    UPDATE 2

    I found this fantastic site. But I have still some problems.