NSDate *date = [components date];
is identical to
NSDate *date = [[components calendar] dateFromComponents:comps];
and it returns nil
if you don't have assigned a calendar to the date components.
You can verify that by setting the environment variable NSObjCMessageLoggingEnabled=YES
in the projects scheme, and observe in the generated message trace (/tmp/msgSends-NNNN
) that
exactly the same methods are called.
That means that you can call
NSDate *date = [calendar dateFromComponents:components];
or
[components setCalendar:calendar];
NSDate *date = [components date];
and there is no difference between the two methods.