8. Dates and Times

In Objective-C, two concepts fall under the general umbrella of time. One is absolute times, the other is time intervals. Time intervals are easy to work with. They are simple scalar quantities, typically measured in seconds. The NSTimeInterval type is used to store time intervals. This is usually defined as a double-precision floating-point value, which gives enough precision for most uses.

You will find some other ways of representing time intervals in various frameworks. One example is the QTKit on OS X, which stores time intervals as rational numbers. This allows you to repeatedly add them without encountering drift due to floating-point rounding errors, which is very important when dealing with media. Over the length of ...

Get Objective-C Phrase Book, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.