Step 1: Changing ViewCarTableViewController

Starting with the .h file, follow these steps:

1. Delete the import of ViewCarProtocol.h.

2. Change the delegate to UIViewController *delegate.

3. Add these block properties:

@property (copy, nonatomic) CDCar* (^carToView)(void); @property (copy, nonatomic) void (^carViewDone)(BOOL dataChanged); @property (copy, nonatomic) void (^nextOrPreviousCar)(BOOL isNext);

One thing to notice is that each block property is marked as copy, not strong. This is very important and is related to how blocks work with external variables. Again, for more information, see Chapter 17 of Learning Objective-C by Robert Clair.

Each of the properties declares a block that replaces the same protocol ...

Get Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming 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.