Pointer variable is a variable itself, so it has an address. So &str1
results in the address of the pointer variable, and str1
is an expression that results in whatever the pointer variable is holding - the address of the object it's pointing to.
Assume that:
- the object holding the NSString "one" is at address 0x00000100
- the object holding the NSString "two" is at address 0x00000200
Then your pointers might look something like this:
At initialization:
str1
0xbfffd3c8 +---------------+
| |
| 0x00000100 |
| ("one") |
+---------------+
str2
0xbfffd3cc +---------------+
| |
| 0x00000200 |
| ("two") |
+---------------+
=======================================
After the str1 = str2;
assignment:
str1
0xbfffd3c8 +---------------+
| |
| 0x00000200 |
| ("two") |
+---------------+
str2
0xbfffd3cc +---------------+
| |
| 0x00000200 |
| ("two") |
+---------------+
Дополнительная ссылка:
stackoverflow.com/questions/529482/objective-c-pointers
0 коммент.:
Post a Comment