Several threads discuss the new Xcode iOS 6 bug that appears 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 mistake made me laugh a little, but it made me think ...
The code I wrote that leads to this error accepts date information from a variety of sources (from date formats, strings, user input, etc.), and I really don't expect every dated date to be valid - I'm fine I know that some of them will be zero, and I am very pleased with the results of such objects.
When I first started programming in Objective-C, one of the functions I read was sending messages to Nile objects . This was great because it meant that I didn't have to worry about walking around zero objects.
Now I have a rude error message from Xcode telling me that I sent a message to the nil object.
Is the conclusion that I should check every object non-zero before using it in methods? Am I doing something completely disgusting when working with null objects?
andybiochem
source share