如何在Swift中将变量"year"设置为当前年份?
使用Calendar和Date:
Calendar
Date
let year = Calendar.current.component(.year, from: Date())