For the More Curious: Redrawing Views

When a UIView instance is sent the message setNeedsDisplay, that view is marked for re-display. View subclasses send themselves setNeedsDisplay when their drawable content changes. For example, UITextField will mark itself for re-display if it is sent the message setText:. (It has to redraw if the text it displays changes.)

When a view has marked itself for re-display, it is not immediately redrawn; instead, it is added to a list of views that need updating. Your application is a giant infinite loop called the run loop. The run loop’s job is to check for input (a touch, Core Location updates, data coming in through a network interface, etc.) and then find the appropriate handlers for that event (like an ...

Get iOS Programming: The Big Nerd Ranch Guide, 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.