0

The code for test:

NSNumber *n1 = @1;
NSNumber *n2 = @2;
NSNumber *n3 = @3;
NSLog(@"\n- %p\n - %p\n - %p\n", &n1, &n2, &n3);

The address number's pointer:

// pointer address of numbers
 - 0x7ffeef66e138
 - 0x7ffeef66e130
 - 0x7ffeef66e128

The pointer need 8 bytes in 64-bit iOS architecture, So I think continuous number's address should increase by 8 bytes. But the test result make me confused.

pkamb
  • 33,281
  • 23
  • 160
  • 191
zox01
  • 66
  • 6
  • 1
    Why are you confused? The values are 8 bytes apart. 0x7ffeef66e138 is 8 more than 0x7ffeef66e130 which is 8 more than 0x7ffeef66e128. Isn’t that what you said you expected? I do not see any “increase by one byte” anywhere here, so what is the question about? – matt Dec 06 '19 at 06:10
  • Might want to read https://stackoverflow.com/questions/2724449/difference-between-word-addressable-and-byte-addressable – matt Dec 06 '19 at 06:17
  • Thanks. I'm wrong because I think the address increase unit is bit. – zox01 Dec 07 '19 at 01:39
  • Yes, LOL. The whole point of bytes is that they, not bits, are what an address addresses. – matt Dec 07 '19 at 03:07

0 Answers0