Tuesday, March 1, 2011

In Cocoa, how to obtain the current hours and minutes in an efficient way?

I want to display current time in my iPhone app using my own custom graphics. What's the most efficient way to get the hours, minutes and seconds info? I thought about using NSDateFormatter to get each part but this seems to be too CPU intensive.

From stackoverflow
  • You'll want to use NSDateComponents. This answer on SO provides an example.

    probablyCorey : Also take a look at this answer on SO. It's a little more specific to your question http://stackoverflow.com/questions/743140/how-do-i-get-the-current-hour-using-cocoa

0 comments:

Post a Comment