Why would we use a pointer in an NSInteger but not in an NSNumber?

796 views Asked by At

I have an NSInteger that doesn't use a pointer and an NSNumber that does use a pointer. Can someone explain to me why this is the case? All my teacher said was the NSInteger is being used as a type alias but I'm not familiar with that either yet.

This question asked a direct question asking for the reason there was no pointer in NSInteger; not asking for all the differences.

enter image description here

1

There are 1 answers

5
matt On BEST ANSWER

Bear in mind that Objective-C is C. Thus:

  • An NSInteger is a scalar, a built-in C data type (an integer). [The actual size of this integer depends on the architecture, 32-bit vs. 64-bit. But it is still some form of C integer.]

  • An NSNumber is an object; Objective-C object references are represented as C pointers.