Replacing a Protocol

Protocols enable one object to communicate with another, without either object knowing anything about the internals of the other. As you have seen, a protocol specifies a contract that the delegate implements the required methods conforming to the specification.

Like a protocol, a block is a contract. One object defines the return value and arguments. The other object writes a block matching the specification.

You have already done this in pulsing the taxi view. The animation call takes two defined blocks. One is a simple block with no arguments and no return value. The other takes one argument. AboutViewController implements the blocks as part of the method call, although you could just as easily define and write them elsewhere ...

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.