Chapter 23. Creating NSFormatters

A formatter takes a string and makes another object, typically so that the user can type something that is more than just a string. For example, the NSDateFormatter, when passed a string like “August 17, 1967”, converts it into an NSCalendarDate object that represents the seventeenth day of August in the year 1967 (Figure 23.1)


Figure 23.1. NSDateFormatter

Also, a formatter can take an object and create a string for the user to see. For example, imagine a text field that has an NSDateFormatter. When the text field is sent setObjectValue: with an NSCalendarDate object, the date formatter will create a string that represents ...

Get COCOA PROGRAMMING FOR MAC OS X SECOND EDITION now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.