Declaring and Calling Methods

As you have already seen, method declarations are very different from what you’re used to seeing in Java and C#. Objective-C instead uses SmallTalk method syntax. Figure C.1 shows a breakdown of the declaration of a static method that takes two parameters and returns an object of type id.

Image

Figure C.1 Method signature.

There are two types of methods in Objective-C: instance and class methods. Instance methods work on specific objects, whereas class methods are similar to static methods in Java and can be invoked using the class name. Class methods do not have access to any data stored in the class properties.

The return ...

Get Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android 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.