A few threads here discuss the new iOS 6 Xcode error that pops up in the console when sending nil dates to Calendar methods:
-[__NSCFCalendar components:fromDate:toDate:options:]: fromDate cannot be nil
I mean really, what do you think that operation is supposed to mean with a nil fromDate?
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.
The error made me chuckle a bit, but got me to thinking....
The code I've written that results in this error takes date information from a multitude of sources (from date formatters, strings, user input, etc), and I really don't expect every date that is supplied to be valid - I know full well that some will be nil, and I'm quite happy dealing with the results of such objects.
When I first started programming in Objective C one of the features I read up on was sending messages to nil objects. This was great because it meant that I didn't have to worry about passing around nil objects.
Now I've got a grumpy error message from Xcode telling me that I've sent a message to a nil object.
Is the inference now that I've got to check every object is not nil before using it in methods? Am I doing something totally heinous working with nil objects?