I have a struct such as :
struct AdData {
var AdRequest = Int?()
var Date = NSDate?() // eg: 2015-11-01 04:00:00 +0000
}
And an array of AdData
:
var RawDataFromDb = [AdData]()
I want to find the all the items in RawDataFromDb
where Date
matches today's date. I figured I somehow have to remove the time component of the AdData
Date
component to compare only the date, but I'm struggling to find an elegant solution.
So far I tried this without success :
public func ==(lhs: NSDate, rhs: NSDate) -> Bool {
return lhs === rhs || lhs.compare(rhs) == .OrderedSame
}
public func <(lhs: NSDate, rhs: NSDate) -> Bool {
return lhs.compare(rhs) == .OrderedAscending
}
extension NSDate: Comparable { }
let TodayDate = NSDate()
let TodayRows = RawDataFromDb.filter{($0.Date == TodayDate}
Thank you for your help !