User Tools

Site Tools


This is an old revision of the document!

Variable Declaration and Access

The location of a variable declaration affects its scope, its lifetime, and the way in which you access it.


Common declaration types

  1. local variables- a variable visible only within the function in which it is declared
  2. private instance variable (aka instance variable)- a variable visible only to the object to which it belongs to
  3. property- a public instance variable*. Visible to other objects. Relies on the keyword @property, automagically generates code at compile time.

Note that other types of declarations exist, these are the most common.

The following are descriptions of each type. Note that each example will use a variable of type NSString named “myString.”

Local Variables

Scope: broadly, only the function in which it is declared Declaration and Usage:

- (void) myMythodName {


[Private] Instance Variables


Behind the Scenes-- Properties

ios-labs-s14/intermediate-scope.1393346557.txt.gz · Last modified: 2014/02/25 10:42 by mbarboi