I know that all instances of NSString are inmutable. If you assign a new value to a new memory line and the old line will be lost.
This is not how volatility works, and how links to NSStrings work. How pointers do not work.
Pointer to an object - NSString *a; declares a variable a , which is a pointer to an object, simply stores the address in the memory of the object. The actual object is [usually] the allocation in the memory heap that contains the actual object itself.
In these terms, there is no run-time difference between:
NSString *a; NSMutableString *b;
Both are references to - addresses - some distribution in memory. The only difference is during compilation, b will be handled differently than a , and the compiler will not complain if, say, you use the NSMutableString methods when calling b (but when calling a ).
How NSMutableString works, it contains an internal buffer (or several buffers - implementation details) that contain string data. When you call one of the methods that mutate the contents of a string, the modified string will reassign its internal memory, if necessary, to contain new data.
Objects do not move in memory. After allocation, the distribution will never move - the object address or distribution will never change. The only exception is when you use something like realloc() , which may return a different address. However, this is really just a sequence of free(); malloc(); memcpy(); free(); malloc(); memcpy(); .
I suggest you return to the Objective-C Programming Guide, or perhaps the C Programming Guide .