How to get to Swift?

advertisements

I'm trying to get the current time, and I've done this so far:

    let date = NSDate()
    let calender = NSCalendar.currentCalendar()
    let components = calender.component([.Hour, .Minute], fromDate: date)

And I then try to get the hour of the components

    let hour = components.hour

This give me "Value of type "Int" has no member 'hour'". Any suggestions?


Change

let components = calender.component([.Hour, .Minute], fromDate: date)

to

let components = calender.components([.Hour, .Minute], fromDate: date)