Hey guys, I have a quick question about the pointer syntax used in Obj-C.
When you deal with numbers, pointers work this way:
int *y;
y = &x;
and then to reference the x variable through y you use *y
Now with strings, it apparently works this way:
NSString *s1;
s1 = @"Test";
and then to reference the string you just use s1
Now my questions is, for strings, why do you just do s1 = @"Test" instead of something like s1 = &@"Test" and to use the value of the string, you just mention the variable name instead of *(variable name)? Does it have something to do with Strings being an object and numbers not? And if so why the difference in syntax?
When you deal with numbers, pointers work this way:
int *y;
y = &x;
and then to reference the x variable through y you use *y
Now with strings, it apparently works this way:
NSString *s1;
s1 = @"Test";
and then to reference the string you just use s1
Now my questions is, for strings, why do you just do s1 = @"Test" instead of something like s1 = &@"Test" and to use the value of the string, you just mention the variable name instead of *(variable name)? Does it have something to do with Strings being an object and numbers not? And if so why the difference in syntax?