Restoring View Controllers

Since the two view controllers have a restoration class, the restoration class will be asked to create new instances of their respective view controller. In BNRItemsViewController.h, have the view controller conform to the UIViewControllerRestoration protocol.

@interface BNRItemsViewController : UITableViewController <UIViewControllerRestoration>

@end

Then, in BNRItemsViewController.m, implement the one required method for this protocol, which will return a new view controller instance.

+ (UIViewController *)viewControllerWithRestorationIdentifierPath:(NSArray *)path
                                                            coder:(NSCoder *)coder
{
    return [[self alloc] init];
}

Now do the same for BNRDetailViewController. Open BNRDetailViewController.h ...

Get iOS Programming: 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.