How do I create an NSDate object with a custom date other than the current date? For example I would like to create a var of yesterday or of 2 days ago.
NSDate
This is a solution for Swift 5.1 - XCode 11
let yesterday = Calendar.current.date(byAdding: .day, value: -1, to: Date())
Accordingly two days ago:
let twoDaysAgo = Calendar.current.date(byAdding: .day, value: -2, to: Date())