In my swift app I've the following function:
func generateTimetable() -> [String:String] {
var dayCellTFText = [String]()
for i in 1...7 {
let cell = tableView.cellForRow(at: [0,i]) as! DayCell
dayCellTFText.append(cell.timetableTextField.text!)
}
let timetable = ["monday":dayCellTFText[0],"thuesday":dayCellTFText[1],"wednesday":dayCellTFText[2],"thursday":dayCellTFText[3],"friday":dayCellTFText[4],"saturday":dayCellTFText[5],"sunday":dayCellTFText[6]]
return timetable
}
When I invoke the function by, for example, print(generateTimetable()) This is the output:
["thuesday": "", "wednesday": "", "saturday": "", "thursday": "", "monday": "", "friday": "", "sunday": ""]
The problem is that the dictionary's elements changed positions! How can I solve this?