我刚刚创建了以下代码作为示例,我正在寻找一种方法从textfield.text获取类型为Month的值并将其分配给let bmonth:
enum Month {
case January, February, March, April, May, June, July, August, September, October, November, December
}
struct BirthDay {
let day: Int
let month: Month
let year: Int
func calculateWesternZodiac() {
// some long code
}
func calculateVedicZodiac() {
// some long code
}
}
// Hardcoding the values
let myBirthday = BirthDay(day: 02, month: .February, year: 1980)
// values from input textField
let bday = Int(dayTextField.text)
let bmonth = Month(monthTextField.text) // I'm looking for the correct way of doing this !
let byear = Int(yearTextField.text)
let yourBirthday = BirthDay(day: bday, month: bmonth, year: byear)
这里的任何人都知道如何做到这一点?