How to find the nearest date of the stored data
<p>For example:</p>

<ul>
<li>stored data: date = data1(2015.12.31), data2(2016.01.05), data3(2016.01.14), data4(2016.01.15), data5(2016.01.18)</li>
<li>today is 2016.01.12</li>
<li>then nearest data is <strong>data3</strong></li>
</ul>

<p>What are the methods that can be called here data3?</p>

<p><code>realDate(datePicker.date), date(textField.text), content(textField.text)</code> in Core Data.</p>

<pre><code>var stores: Contact!
// Contact is CoreData Entity Name.
@IBOutlet weak var label: UILabel!
</code></pre>

<p>ViewController viewDidLoad :</p>

<pre><code>let list = [stores]
let timeSort = list.map{_ in stores?.realDate!.timeIntervalSinceNow}.filter{$0 &gt; 0}.sort(&lt;)
  if let firstTime = timeSort.first {
  _ = NSDate(timeIntervalSinceReferenceDate: firstTime!)
    if timeSort.first != nil {
      label.text = stores?.content
    } else { }
  }
</code></pre>

<p>I was trying to get help for writing code. There is no error, it does not display any information on the label.</p>