Created
April 6, 2017 06:53
-
-
Save michal-majchrzycki/b7602651488b151c1d1e3ede1646ff42 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func arrayOfDates() -> NSArray { | |
let numberOfDays: Int = 14 | |
let startDate = Date() | |
let formatter: DateFormatter = DateFormatter() | |
formatter.dateFormat = "EEE d/M" | |
let calendar = Calendar.current | |
var offset = DateComponents() | |
var dates: [Any] = [formatter.string(from: startDate)] | |
for i in 1..<numberOfDays { | |
offset.day = i | |
let nextDay: Date? = calendar.date(byAdding: offset, to: startDate) | |
let nextDayString = formatter.string(from: nextDay!) | |
dates.append(nextDayString) | |
} | |
return dates as NSArray | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment