Book Image

Objective C Memory Management Essentials

Book Image

Objective C Memory Management Essentials

Overview of this book

Table of Contents (18 chapters)
Objective-C Memory Management Essentials
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating custom methods


In Objective-C, methods when declared start with or +, as you will see in this section. The latter declares a static method, while the former, , declares instance methods. As a developer, you won't declare static methods (starting with +) regularly.

Static methods are generally used if you don't need an instance of a class in that method, while instance methods are used when you need that instance to modify its state. Instance methods are more commonly used as instance methods give you access to a class instance variables.

To declare a method, you follow a syntax. You will need the following entities:

  • The symbol to specify the type of the method

  • The type of the data it will return

  • The method's name

  • For each parameter:

    • The type of parameter

    • The name of parameter

  • Your code inside the method

Following our example, in mySpecialTableViewController, let's declare an instance method that will take one parameter, a string (NSString). Our method will return the content of the myProgrammingLanguages...