-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
selected date as Nullable #264
Comments
Hi @danielCarlosCE if let dateNonNull = yourDate {
calendar.selectDate(dateNonNull)
} |
That's what I did, thanks. However, wouldn't be better knowing in compile time? I didn't know it could be nil until I actually got an error in run time. |
Hello, I am wondering why is selectedDate Date type, instead of optional Date (Date?). I am running to run time error, when user hadn't select any date (or after calling deselect(_:)) and the selectedDate property is crashing my app. I would use optional binding to check if there is selected date or not, but there is no optional to bind. |
That was my point @ashhanai . I only find out that it could be nil when my code broken on production. |
So if I understand it right, if I filter items depending of selected date, I cannot let user not to select any date, right? And if I ask for selected date and user doesn't have any, it will crash. My proposal is to make selectedDate optional as it can be nil, when user does not have any selected date. |
@ashhanai The crash has been prevented. But I'll make it optional, thanks for the proposal:) |
I was trying to use selectedDate, but at some point at time, that property was nil. I couldn't prevent the crash since when ported to Swift, that property is of the type NSDate instead of NSDate?
The text was updated successfully, but these errors were encountered: