我有一個文本字段,在視圖 - 控制7個按鍵如何分配工作日到按鈕?
@IBOutlet weak var courseDesc: UITextField!
@IBOutlet weak var sundayButton: UIButton!
@IBOutlet weak var mondayButton: UIButton!
@IBOutlet weak var tuesdayButton: UIButton!
@IBOutlet weak var wednedayButton: UIButton!
@IBOutlet weak var thursdayButton: UIButton!
@IBOutlet weak var fridayButton: UIButton!
@IBOutlet weak var saturdayButton: UIButton!
如何將這些7工作日分配低於上述7個按鍵,例如,如果用戶點擊sundayButton
,應該當用戶保存它被指定爲Sunday
。
func getWeekDay() -> [String] {
let calendar = NSCalendar(calendarIdentifier: NSCalendar.Identifier.gregorian)!
calendar.locale = NSLocale.current as Locale
return calendar.weekdaySymbols
}
var assignDay = getWeekDay()
let sunday = assignDay[0]
let monday = assignDay[1]
let tuesday = assignDay[2]
let wednesday = assignDay[3]
let thursday = assignDay[4]
let friday = assignDay[5]
let saturday = assignDay[6]
您可能需要將其分解爲更小的部分。我不明白你想要做什麼。我們將更有可能幫助您解決小型個人編碼任務,而不是一個大概念。 – Frankie
@Frankie,請參閱編輯問題 – Coder221
這與核心數據有什麼關係? – matt