title: Fetching the most recent item from CoreData in Swift
body: <p>I'm new to CoreData, have read a few tutorials but have come up empty-handed. Most tutorials have centered around fetching from CoreData to populate a tableview, which is not what I'm doing at the moment.</p>
  
  <p>Here's how I'm setting the data in CoreData. All types are <code>Double</code> except for date which is an <code>NSDate</code></p>
  
  <pre><code>let appDelegate = (UIApplication.sharedApplication().delegate as AppDelegate)
  
  let managedObjectContext = appDelegate.managedObjectContext
  let entityDescription = NSEntityDescription.entityForName("Meditation", inManagedObjectContext: managedObjectContext!)
  let meditation = NSManagedObject(entity: entityDescription!, insertIntoManagedObjectContext: managedObjectContext!)
  
  meditation.setValue(settings.minutes, forKey: "length")
  meditation.setValue(settings.warmup, forKey: "warmup")
  meditation.setValue(settings.cooldown, forKey: "cooldown")
  meditation.setValue(NSDate(), forKey: "date")
  
  // fetch stuff from CoreData
  var request = NSFetchRequest(entityName: "Meditation")
  var error:NSError? = nil
  var results:NSArray = managedObjectContext!.executeFetchRequest(request, error: &amp;error)!
  
  for res in results {
      println(res)
  }
  </code></pre>
  
  <p>Here's what I'm trying to do to get the results, but I'm not able to access things like <code>.minutes</code>, <code>.date</code>, etc. I know I'm also not properly getting the last item either, I was just trying to print out attributes on the object first. </p>
  
  <p><strong>I'd love help on how to fetch only the most recent object as well as show it's attributes</strong></p>
  
  <p>Thanks!</p>