Date formatters, lazily instantiated once I would like to create two date formatters only on first call. In Objective-C I would use dispatch_once() but now working in Swift. Am I doing it correctly? My code is based on example that was using class instead of static but it looks like it's Swift 2.0 doesn't support it yet.

class HomeContentItem : NSObject {
    var hideDescription:Bool = false
    var expanded:Bool = true

    var imageURL:String?
    var titleShort:String?
    var textBody:String?
    var sectionName:String?
    var dateString: String?
    var watermarkImage:UIImage?

    var moreTappedAction: ((AnyObject) -&gt; (Void))?
    var sectionNameTappedAction: ((AnyObject) -&gt; (Void))?
    var selectedItemAction: ((AnyObject) -&gt; (Void))?

    static let sameDayFormatter = { (Void) -&gt; NSDateFormatter in
        let formatter = NSDateFormatter()
        formatter.dateFormat = "hh:mm"
        return formatter
        }()

    static let differentDayFormatter = { (Void) -&gt; NSDateFormatter in
        let formatter = NSDateFormatter()
        formatter.dateFormat = "yyyy/MM/dd"
        return formatter
        }()

    func setDate(date:NSDate) {
        if date.isSameDateAs(NSDate()) {
            self.dateString = HomeContentItem.sameDayFormatter.stringFromDate(date)
        } else {
            self.dateString = HomeContentItem.differentDayFormatter.stringFromDate(date)
        }
    }
}


And extention to date:

extension NSDate {
    func isSameDateAs(date : NSDate) -&gt; Bool {
        let firstCalendar = NSCalendar.currentCalendar().components([NSCalendarUnit.Year, NSCalendarUnit.Month, NSCalendarUnit.Day], fromDate: self)
        let secondCalendar = NSCalendar.currentCalendar().components([NSCalendarUnit.Year, NSCalendarUnit.Month, NSCalendarUnit.Day], fromDate: date)
        return (firstCalendar.day == secondCalendar.day &amp;&amp;
            firstCalendar.month == secondCalendar.month &amp;&amp;
            firstCalendar.year == secondCalendar.year)
    }
}
This isn't the way to compare two dates...it violates one of my commandments.  We can &amp; should use NSCalendar's compareDate method:

extension NSDate {
    func isSameDayAs(date: NSDate) -&gt; Bool {
        let calendar = NSCalendar.currentCalendar()
        let dif = calendar.compareDate(self, toDate: date, toUnitGranularity: .DayCalendarUnit)
        return dif = .OrderedSame
    }
}




Moreover, your date formatter methods don't have any business in the view controller.  These make more sense also as NSDate extension methods.  However, creating NSDateFormatters is actually a pretty expensive operation.  We don't want to do it more often than necessary.  So, let's make a struct to handle one formatter per style we want:

extension NSDate {
    private struct Formatters {
        static let timeFormatter = { (Void) -&gt; NSDateFormatter in
            let formatter = NSDateFormatter()
            formatter.dateFormat = "hh:mm"
            return formatter
        }()

        static let yearMonthDayFormatter = { (Void) -&gt; NSDateFormatter in
            let formatter = NSDateFormatter()
            formatter.dateFormat = "yyyy/MM/dd"
            return formatter
        }()
    }

    var timeString: String {
        get {
            return Formatters.timeFormatter.stringFromDate(self)
        }
    }

    var yearMonthDayString: String {
        get {
            return Formatters.yearMonthDayFormatter.stringFromDate(self)
        }
    }
}


Importantly, using this approach makes unit testing (which you should definitely be doing) quite easy.  And, we've put code in places where it makes sense.