我想要获得当前时间,到目前为止我已经完成了这个: let date = NSDate() let calender = NSCalendar.currentCalendar() let components = calender.component([.Hour, .Minute], fromDate: date) 然后我尝试获取组件的小时
let date = NSDate() let calender = NSCalendar.currentCalendar() let components = calender.component([.Hour, .Minute], fromDate: date)
然后我尝试获取组件的小时
let hour = components.hour
这给了我“类型的价值”Int“没有成员’小时’”.有什么建议?
更改let components = calender.component([.Hour, .Minute], fromDate: date)
至
let components = calender.components([.Hour, .Minute], fromDate: date)