On a device, If I have a string, say "04:00 PM" and convert it to a date using a dateformatter:
let dateFormatter = DateFormatter() dateFormatter.format = "h:mm a"
let d = dateFormatter.date(from: "04:00 PM")
If the device is set to a 24 hour time format, then d is nil. On a simulator, the result is a date. What I want to do is to somehow set up the simulator to return a nil under this circumstance. How do I do that?
Things I have tried: setting 24-hour format on the Mac, setting the region on the Mac, setting the region on the simulator, setting the locale in the simulator (maybe there's a locale setting I missed). For the Mac update settings, I reset the simulator afterward for the change to take effect.
So far nothing I've tried works.
The purpose of this is to allow automated tests to be able to detect these nils that will happen on actual devices.