Я работаю над разработкой ios, и мне очень сложно проверить, есть ли два NSDate с одного дня. Я попытался использовать этот
fetchDateList()
// Check date
let date = NSDate()
// setup date formatter
let dateFormatter = NSDateFormatter()
// set current time zone
dateFormatter.locale = NSLocale.currentLocale()
let latestDate = dataList[dataList.count-1].valueForKey("representDate") as! NSDate
//let newDate = dateFormatter.stringFromDate(date)
let diffDateComponent = NSCalendar.currentCalendar().components([NSCalendarUnit.Year, NSCalendarUnit.Month, NSCalendarUnit.Day], fromDate: latestDate, toDate: date, options: NSCalendarOptions.init(rawValue: 0))
print(diffDateComponent.day)
но он просто проверяет, имеет ли два NSDates разницу в 24 часа. Я думаю, что есть способ заставить его работать, но все же, я хочу, чтобы значения NSDate до 2 часов утра были засчитаны как накануне, поэтому мне определенно нужна помощь здесь. Спасибо!