Archive for abril \19\UTC 2011

Handling dates in objective-c can be quite difficult if you don’t use the right tools.

And the best tools are for sure the NSDateComponents class. This class is available to both Mac and iOS development, and it makes handling dates much more simple.

Suppose that you need to get the month number of a date. If you don’t know NSDateComponents, a way to do that is create a NSDateFormatter and set the format only for the month and get a string that you could convert to a number. Simple  like that. Actually this is far from simple, and far from optimal and far from good programming practices.



Read Full Post »