A pointer is simply a handle, location, or memory address. So you with a pointer, you're not directly manipulating a thing, you're manipulating something in memory at which the pointer points.
However, with a scalar value like an int, you are working directly with that piece of data. How a given language uses pointers and values is up to the language, so there are implications as to where they are stored, how they are accessed, etc.
That's not the whole story, but it's the easiest way to explain it IMHO.
Now, in the context of Objective-C, you wouldn't really find many pointers to an int type, you would find an int value. Objects on the other hand use pointers like crazy, and it's what allows you to pass around an Object to a method, or send it in a message, modify it, and still have the same object, just mutated.
However, with that int, passing it as a message parameter will surely pass the value of the int, but not a reference to it, so the original int will remain intact.
Here is some documentation on pointers
And here is an example in Objective-C to point it out
Let's assume for a moment we have a simple iOS or OSX app following Apple's Objective-C standards and libraries. Let's also assume we have a class, Foo, with the appropriately defined header
#import Foo.h
#import Bar.h
@implementation Foo
- (void) doSomethingWithPointer:(Bar)obj{
obj.x = 5;
}
- (void) doSomethingWithValue:(int)num{
int x = num;
}
- (void) doThings:{
//Suppose I have an object of type Bar available to me. I'm going to get a pointer to a new instance of that object, freshly allocated into memory
Bar *barObj = [Bar alloc];
//we will assume Bar has only one feature, a publicly accessible property called x. It's of the int type, of value 1, but again, is part of the Bar object that we are POINTING to.
//Now, here is a variable that is NOT a POINTER, it's merely a value in memory.
int num = 1;
//Let's call the two methods in this class that perform some action and see what happens.
//first, our pointer
NSLog(@"%d",barObj.x);//outputs 1
[self doSomethingWithPointer:barObj];
NSLog(@"%d",barObj.x);//outputs 5
//Now, let's call on our variable that is just a value and NOT a POINTER
NSLog(@"%d",num);//outputs 1
[self doSomethingWithValue:num];
NSLog(@"%d",num);//outputs 1
}
@end
What I have demonstrated here is not just the concept of a pointer, but also of passing by reference. Aside from that, I have also shown what the difference is between a pointer and a scalar value represented by a variable. When we passed "variable", as you call it, to a method, it's modified in the method, but as you can see the original was kept in tact and did not change after what was used in the method was. Only the value was passed and not the reference to that original value.
However, in the case of the object, we passed a pointer to the object. Since we modified the object represented by that point, at THAT location in memory, the value inside the object DID change because we were in essence acting on the same object. We knew where to look for it in memory.
If this is still not making sense just let me know in the comments and we'll figure this thing out :)
I'm going to assume you come from either a scripting or Java background if you don't know pointers that well ;)
As a side note, why is this the case only with objects in obj-c it would seem?
Objects, or rather instances of Classes, encapsulate data, and that data needs to be able to remain intact and passed around, but if mutated, that mutation needs to also be reflected in the object's state no matter where that same instance of the object is used.