Issue with UIDatePicker causing Application Crash

Hi everyone,

I'm encountering a frustrating issue with UIDatePicker in my iOS application and would greatly appreciate any insights or assistance in resolving it.

Description: Upon adding a UIDatePicker to my UIViewController using the drag-and-drop method, the date picker functions correctly, allowing users to select dates without any issues. However, when attempting to change the year by tapping on the month and year view, the application crashes with the following error message:

Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'

This issue occurs consistently with both the compact and inline styles of UIDatePicker.

Steps to Reproduce:

  1. Add a UIDatePicker to a UIViewController using the Interface Builder.
  2. Run the application on a device or simulator.
  3. Open the UIDatePicker.
  4. Tap on the month and year view to change the year.

Expected Behavior: The application should allow users to change the year in the UIDatePicker without crashing.

Actual Behavior: The application crashes with the error message mentioned above when attempting to change the year.

Additional Information:

This issue occurs regardless of the date picker's configuration or settings. I've tried various troubleshooting steps, including checking for conflicts with other components and reviewing the view hierarchy, but have been unable to identify the root cause of the problem. If anyone has encountered a similar issue or has any suggestions for resolving this issue, I would be grateful for your assistance.

Attached screenshots of implementation and stack trace.

Which version of Xcode ?

I tested with exact same configuration on Xcode 15.0.1

and ran on simulator iOS 17.0 without issue.

Before change:

Tap on date:

Change year:

Close the picker and get the correct date:

Have you any code using the Date Picker ?

have you defined DatePicker connections ?

Xcode version is - 15.0, the date picker outlet isn't connected. Also want to state that if I tried creating new project and mimic the same it works, but not working on any screen in my existing project, tried on multiple screens but same behaviour throughout the project.

I repeated the test, with a new datePicker, without any connection.

No issue either.

You have probably an issue in code.

Did you try to do a Clean Build Folder ?

If not working, could you send the code of the ViewController ?

I see you have defined constraints. Could you show them ?

There is a reference to a TableView. Have you created any ? If so, error may lie there. Please post the code in that case.

The issue was due to pod 'SkeletonView', this was the reason of crash.

Issue with UIDatePicker causing Application Crash
 
 
Q