0
投票
在编写代码时不要使用强制解包。如果你的变量保持零值,它将崩溃
改变你的代码
let dayComponent = calendar.component(.day, from: date!)
至
if let convertedDate = date {
let dayComponent = calendar.component(.day, from: convertedDate)
}
0
投票
在编写代码时不要使用强制解包。如果你的变量保持零值,它将崩溃
改变你的代码
let dayComponent = calendar.component(.day, from: date!)
至
if let convertedDate = date {
let dayComponent = calendar.component(.day, from: convertedDate)
}