I am having a terrible time trying to do something that should be easy. I have a NSNumber value of 32025.89 seconds. I need to represent that in Hours, Minutes, Seconds. Is there a method that spits that out? I can't seem to find a proper formatter.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- back button text does not change
- iOS (objective-c) compression_decode_buffer() retu
- how to find the index position of the ARRAY Where
相关文章
- 现在使用swift开发ios应用好还是swift?
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- How can I add media attachments to my push notific
- didBeginContact:(SKPhysicsContact *)contact not in
- Custom Marker performance iOS, crash with result “
- Converting (u)int64_t to NSNumbers
NSNumber *valueForDisplay = [NSNumber numberWithDouble: [self valueForDisplay:clockName]];
Have you tried creating an
NSDate
from that and printing that using anNSDateFormatter
?If you need the individual values for hours, minutes, and seconds, use
NSDateComponents
as suggested by nall.The above won't print the correct amounts if the
NSNumber
represents more than one day. It could be 1 day and 1 hour, and it would only print 01:00:00. In such a case you should calculate hours, minutes and seconds manually.Here's a way without any libraries except for
modf()
frommath.h
:If you don't want to just divide it out, try this. It may be close enough for your purposes. Note: It doesn't account for sub-second precision. (
setSecond
takes anNSInteger
).