10 Formatters and Validation

Users are complicated. They have strong opinions about how they want to input and see data. As a developer, you want to support their whims, to get that I thought it might do this and it does! reaction. With formatters your text fields can present and accept data textually without cluttering your controller. Formatters also provide validation at the controller layer, while Key-Value Validation allows you to validate at the model layer.


Formatters convert strings into data and data into strings. In the same way that an array controller is a lens for an array, changing the model of your application into a representation for the view layer, a formatter is a lens for one piece of data ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide 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.