Table of Contents Previous Section
Variables
To declare a variable in WebScript, use the syntax:
id myVar; id myVar1, myVar2;In these declarations, id is a data type. The id type is a reference to any object-in reality, a pointer to the object's data (its instance variables). Like a C function or an array, an object is identified by its address; thus, all variables declared in WebScript are pointers to objects. In the examples above, myVar1 and myVar2 could be any object: a string, an array, or a custom object from your application.
Note: Unlike C, no pointer manipulation is allowed in WebScript.
Instead of using id, you can specifically refer to the class you want to instantiate using this syntax:
className *variableName;For example, you could specify that a variable is an NSString object using this syntax:
NSString *myString1;For more information on specifying class names in variable declarations, see the section "Data Types".
NSString *myString2, *myString3;
id instanceVariable; // An instance variable for this class.
- aMethod {
id localVariable1; // A local variable for this method.
while (1) {
NSString *localVariable2; // A local variable for this block.
}
}
Table of Contents Next Section