I'm using an extension to NSDate:
extension NSDate {
func toDayMonthYear() -> String {
let formatter = NSDateFormatter()
formatter.dateFormat = "dd.MM.yy"
return formatter.stringFromDate(self)
}
}
This way I can easily turn any values to NSDate
print(NSDate().toDayMonthYear) => "12.11.2015"
But I understand that each and every time this gets called, an instance of NSDateFormatter is created which is - performancewise - catastrofic...
How can I do that more elegantly?