Get number of days between two dates swift

Get number of days between two dates in siwft

Want to calculate number of days between two dates in iOS using swift. Or difference of days between two dates in swift. Below is the code snippet, written in swift that will return number of days between two dates.

//MARK:- daysBetween
    func daysBetween(start: Date, end: Date) -> Int {
        return Calendar.current.dateComponents([.day], from: start, to: end).day!
    }

Get number of days between two dates in Objective C

In above code, we will pass two date objects. Start date and end date. Function will return us the count of days between the two dates as integer.