title: Convert NSDate to Date
body: <p>this might be a stupid question, but I can´t find the information. I'm using CoreData in my app, and I save an array of structs. The problem is when I fetch and try to restore it into the struct array, I have a problem with my Date variable; I can't find a way to convert it from NSDate to Date, I try using <code>as Date</code>, but it makes me force downcast and I'm not sure if it's safe. Is it correct? or is there another way? </p>
  
  <p>This is my Struc: </p>
  
  <pre><code>struct MyData {
          var value = Int()
          var date = Date()
          var take = Int()
          var commnt = String()
      }
  </code></pre>
  
  <p>This is how I'm fetchin the data: </p>
  
  <pre><code>func fetchRequestInfo() -&gt; [MyData] {
  
          let fetchRequest: NSFetchRequest&lt;GlucoseEvents&gt; = GlucoseEvents.fetchRequest()
  
          do {
              let searchResults = try DatabaseController.getContext().fetch(fetchRequest)
  
              for result in searchResults as [GlucoseEvents] {
                 let value = Int(result.value)
                 let date = result.date as Date
                 let take = Int(result.take)
                 let commnt = String(describing: result.commnt)
                  let data = MyData(value: value, date: date, take: take, commnt: commnt)
                 self.dataArray.append(data)
                  }
  
  
  
              } catch {
  
                  print ("error: \(error)")
  
              }
          let orderArray = self.dataArray.sorted(by: { $0.date.compare($1.date) == .orderedAscending})
          return orderArray
      }
  </code></pre>
  
  <p>And this is the how I set the properties of my CoreDataClass:</p>
  
  <pre><code>@NSManaged public var commnt: String?
      @NSManaged public var date: NSDate?
      @NSManaged public var value: Int16
      @NSManaged public var take: Int16
  </code></pre>