Now I've got a grumpy error message from Xcode telling me that I've sent a message to a nil object.
Incorrect. Your NSCalendar
(the receiver) is not nil. What's nil
is the NSDate
you're passing as one of the arguments to the method. NSCalendar
doesn't have any clue what to do when you give it a nil NSDate
, so it gives you a log message instead of throwing an exception and crashing your app.