You should use NSString when you need a string as a fixed (immutable) string value and NSMutableString as an editable (mutable) string container (buffer) .
If you're not sure, use NSString first. In most cases, it will provide better overall performance.
Why do I prefer NSString ?
Value
NSString never changes. This means that you can be sure that once made NSString will be the same as forever, no matter what you do on it. This way you can trust a once-validated string value without additional verification. This reduces the complexity of the program and significantly increases the cost.
NSMutableString does not have such a guarantee. After you passed NSMutableString to some function or method, now you cannot find out its current value. Now you need to check or check again.
You may think that you know what will change or not. But for large programs or code in other people, this is difficult to determine. Just using NSString simplifies this, so you will have fewer problems to worry about.
How is NSString more efficient, although it needs to allocate a new object for every row change?
For a general program, in fact, you do not always change lines. In fact, many string values do not need to be changed. You assign or copy strings in the same way as much more. When you copy NSMutableString , it makes an exact copy, and this requires a CPU resource, memory access, memory space. NSString does not require the actual copy operation because it is not copied. This is possible because it cannot be changed (unchanged), so it just reuses itself. Almost not worth it.
And you should have a relatively small piece of code that requires intensive line editing. Use NSMutableString there. Since NSString cannot be changed, it needs to create a new object when you need a new string value. This is an inefficient and almost the only inefficient NSString point.
The only NSMutableString pros are in-place editing support. In other words, when creating a new string value, you do not need to create new objects. Thus, you can save the cost of creating an object if you need to make a lot of changes.
Cocoa, designed to use this separation mutation. You will find that you need to declare @property (copy) instead of @property (strong) so that objects are not affected by any changes elsewhere in the program. NSString very efficient here, unlike NSMutableString , you need to copy it every time.
This is the same for all NS~/NSMutable~ classes.