9. Perform Selector and Delayed Perform

Selectors identify the messages that are sent to Objective-C objects. They’re used by the receivers of messages to select which methods will be performed. Selectors provide much of the power, flexibility, and dynamism of the Objective-C language, and they’re used to implement other Cocoa design patterns. In particular, selectors are key to Cocoa’s implementation of the Notifications, Delegates, Targets and Actions, Invocations, and Forwarding patterns. Using selectors, Cocoa objects can be asked to perform methods immediately or after arbitrary time delays. Delaying the performance of methods can be very handy and is sometimes used to keep a user interface responsive while long-running tasks complete, ...

Get Cocoa Design Patterns 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.