0

I'm new in objective-C and I have a question about pointers

I know when I want to store an address instead of a value I use pointers

and in order to get an address, I have to use the &variableName

in objective-C, in order to make an object, I have to do the following:

ClassName *theObject = [[ClassName alloc] init];

which means I'm storing the address of ClassName in the object theObject

which is the same idea as:

ClassName *theObject = &ClassName; //(Correct me if i'm wrong please);

but my question is when I make an object of int, float, double, char I don't create the object as explained above, the only thing I do is:

int object = 7;

why is it different in int, double, char, etc... ? they are not interfaces or what?

Zyz
  • 123
  • 1
  • 9
  • Possible duplication of https://stackoverflow.com/questions/11031732/what-is-the-difference-between-primitive-data-type-vs-an-non-primitive-data-type – Pavel Oganesyan Feb 06 '20 at 12:37
  • You can work with pointers at int, double and char. Just add `*`. `*` - is mark that this is pointer. Even pointers at pointers are exists. There is opposite restriction: you can't create `NSObject`s as values. – Cy-4AH Feb 06 '20 at 14:22
  • See [Understanding pointers?](https://stackoverflow.com/questions/9746683/understanding-pointers) – Willeke Feb 06 '20 at 14:44
  • See [When to and when not to use pointers in Objective-C](https://stackoverflow.com/questions/5074369/when-to-and-when-not-to-use-pointers-in-objective-c) – Willeke Feb 06 '20 at 14:44
  • See [need of pointer objects in objective c](https://stackoverflow.com/questions/17992127/need-of-pointer-objects-in-objective-c) – Willeke Feb 06 '20 at 14:44
  • I still see people memorizing instead of understanding, my question was tooooo clear but the answers you referred too are too general I already know it, thanks I don't need your answer – Zyz Feb 07 '20 at 20:14

0 Answers0