Learning Objective-C 2.0: A Hands-on Guide to Objective-C for Mac and iOS Developers, Second Edition
by Robert Clair
5. Messaging
In Objective-C, when you want an object to do something, you send the object a message. In response, the object executes one of its methods. This is not quite the same thing as calling a function. Functions are usually statically bound—the code that the function executes is determined when the program is compiled. Using messaging, the actual code that is executed in response to a message is determined at execution time.
In this chapter you will learn how Objective-C messaging works. The chapter covers methods, message expressions, and the machinery of the messaging system.
Methods
The structure of an Objective-C method is very similar to that of a C function (in fact, the compiler eventually turns the methods into C functions). There ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access