Performance, Brevity and The Convention In the Book


I noticed one of the answers to the challenge question used an initWithString instance method for the NSDate class which I thought was really nice for its brevity. On the other hand is the NSDateComponents class involve less compiling and run faster and is a better habit if we are concerned with performance and don’t mind typing more?


Programmers typically lean toward the briefest readable solution. initWithString: is definitely brief and readable. So it is probably a great way to go.

NSDateComponents useful because it acts as a bridge between a particular calendar and NSDate. In this exercise, however, it is probably overkill.


OK, I think I get it so NSDate is always Gregorian and NSDateComponents Lets us set a calendar type to something like a lunar calendar if need be. Thank you for that.


Actually, NSDate is always the number of seconds since the dawn of 1970 in Greenwich – with no particular calendar. When we display it, we specify calendar. (There is a default calendar for your computer, which seems to be gregorian.)


So when we use the initWithString method with NSDate we are able to change the start date is all? This also got me to wondering is there a simple way to count months with information, the seconds and calendar?