I want to get an array of Strings years like monthSymbols.
example: [2017, 2018, 2019, 2020,... 2100]
I do that with the month of year:
let formatter = DateFormatter()
let monthComponents = formatter.monthSymbols
but I can't do the same with the years. any help?
I don't think such a thing exists. An arbitrary list of years can't really be handled in the same way as a specific list of month names.
let years = (2017...2100).map { String($0) }
is probably the cleanest way to do what you're looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With