0

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.

Jay
  • 19,649
  • 38
  • 121
  • 184
Boon
  • 40,656
  • 60
  • 209
  • 315
  • Care to explain how you came to that conclusion with NSDateFormatter? I could imagine that changing the format string several times a second could seriously slow it down, but what if you used one formatter per component? – Mike Abdullah Sep 25 '09 at 09:04

1 Answers1

1

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

Community
  • 1
  • 1
progrmr
  • 75,956
  • 16
  • 112
  • 147
  • 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 – probablyCorey Sep 24 '09 at 23:06