O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Naming Conventions

Several naming conventions have become widespread within the Objective-C community. To create code that your peers can maintain more easily, try to use the following conventions:

  • Always capitalize class names.

  • Begin variable and method names with lowercase letters. If a variable or method name consists of multiple words, capitalize the first letter of the second and any following words. This practice is known as camelcase.

  • Begin accessor methods that set an instance variable value with the word “set,” and make sure the instance variable name follows in camelcase.

  • Give accessor methods that return the value of an instance variable the same name as the variable. It is also acceptable—though uncommon—to prefix the variable name with the word “get” and have the instance variable name follow in camelcase.

  • Do not begin method names that you create with an underscore. By convention, Apple uses underscores to implement system level private functionality.

We’ve implemented these conventions throughout the book.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required