Exploring the Recipe

Recipe 7-6 handles its delegate and data source duties by tagging each view controller’s view with a page number. It uses this number to know exactly which page is presented at any time and to delegate another class, BookDelegate, to produce a view controller by index.

The page controller itself always stores zero, one, or two pages in its view controller array. Zero pages means the controller has not yet been properly set up. One page is used for spine locations on the edge of the screen, two pages for a central spine. If the page count does not exactly match the spine setup, you will encounter a rather nasty runtime crash.

The controllers presented in those pages are produced by the two data source methods, which implement ...

Get The Core iOS Developer’s Cookbook, Fifth 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.