title: Using coordinates saved in Core Data to draw on a mapview
body: <p>I have a list of coordinates stored in Core Data, along with the time at which they were saved, in the following format:</p>
  
  <p>game - Integer 16</p>
  
  <p>latitude - Double</p>
  
  <p>longitude - Double</p>
  
  <p>time - Date</p>
  
  <p>I have managed to take the user's location and store it in Core Data without issue, but I am having trouble retrieving it and displaying it on a map. I have tried looking for a suitable tutorial, but I can't find anything that combines the Core Data and the MKPolyline aspects of my query. I'm quite new to coding in general and I can't quite align the two.</p>
  
  <p>So, I know the following code will help me draw on to the map:</p>
  
  <pre><code>var coordinates = locations.map({ (location: CLLocation) -&gt; 
  CLLocationCoordinate2D in
      return location.coordinate
  })
  
  var polyline = MKPolyline(coordinates: &amp;coordinates, 
                          count: locations.count)
  </code></pre>
  
  <p>And I already have this in my code to get the Core Data:</p>
  
  <pre><code>@IBOutlet weak var mapView: MKMapView!
  
  var locationsList: [Locations] = []
  
  var contextMap = (UIApplication.sharedApplication().delegate as AppDelegate).managedObjectContext!
  
      var requestMap = NSFetchRequest(entityName: "Locations")
      let predMap = NSPredicate(format: "game = %d", gameNumber)
      requestMap.predicate = predMap
      requestMap.sortDescriptors = [NSSortDescriptor(key:"time", ascending: false)]
  
      self.locationsList = context.executeFetchRequest(requestMap, error: nil)! as [Locations]
  </code></pre>
  
  <p>But I just can't marry the two up in order to take my coordinates from Core Data and put them on the map.</p>
  
  <p>Any help would be great - thanks.</p>