Say I have the following code which initializes an NSDateComponents:
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [[NSDateComponents alloc] init];
[components setYear:1987];
[components setMonth:3];
[components setDay:17];
[components setHour:14];
[components setMinute:20];
[components setSecond:0];
And now I want to convert the components to an NSDate. It seems like there are two ways:
Method 1:
NSDate *date = [calendar dateFromComponents:components];
Method 2:
NSDate *date = [components date];
Is there a difference between these two methods? If so, which one should be used and why?