I\'m trying my hand at the iPhone course from Stanford on iTunes U and I\'m a bit confused about pointers. In the first assignment, I tried doing something like this
The reason that you don't declare NSInteger with a * is because it isn't an object. An NSInteger is simply an int or a long:
#if __LP64__
typedef long NSInteger;
#else
typedef int NSInteger;
endif
If it's being used in a 32-bit application, it's a 32-bit integer, and if it's being built in a 64-bit application, it's a 64-bit integer.
Of course, you can pass an NSInteger as a pointer, but most functions simply take arguments as an NSInteger and not a pointer to it.
Objects, on the other hand, can only be passed to other functions as pointers. This is because objects have memory dynamically allocated for them, and so cannot be declared on the stack. Since an int or long has a fixed amount of memory allocated for them, this is not an issue.