Hilarious Xcode Error Message
I’ve been working on an iOS App recently which deals with several date methods. Usually when something goes wrong Xcode displays very dry messages such as “Array out of bounds” or something rather unhelpful (like the complete stack output with no clue as to what actually went wrong).
I was accidentally passing nil into an NSDateComponents method – and instead of crashing (which is what I would have expected), Xcode displayed this super funny message in the log console:
toDate cannot be nil
I mean really, what do you think that operation is supposed to mean with a nil toDate?
An exception has been avoided for now. A few of these errors are going to be reported with this complaint, then further violations will simply silently do whatever random thing results from the nil.
It made me smile 🙂
I think we should have more error messages like this! Here’s a screenshot: