A pointer variable holds a memory address. In other words, a pointer variable points to a value stored at a specific address in memory. Take a look at this image to see what I mean.
The pointer variable *bookTitle, points to the memory address 1 and the value Hush is stored at that address. Variable naming rules discussed in the previous lesson also apply to pointer variable declaration.
Difference Between a Variable and a Pointer Variable
This table summarizes the difference between a regular variable and a pointer variable.
|A regular variable is designed to hold a value declared as an int, double, char, float, or const char.||A pointer variable is designed to hold a memory address. When you declare a pointer variable, place an asterisk (*) infront of its name. In the Objective-C programming language, a pointer is used for creating a pointer variable. Once you’ve created an pointer variable, you can use it as if it were a normal variable or an object variable, if you will.|
double hoursWorked = 7;
NSString *stringObject = @"This is a string object."
The Foundation Framework contain many classes for creating and manipulating object variables. In future lessons, I will introduce you to classes of the Foundation Framework you will use in every day app development. I call them common classes.