The assignment is just that. The string
pointer is basically a label that points to specific address in memory. Reassignment statement would point that label to another address in memory!
It doesn't change reference counting or do anything beyond that in Objective-C. You need to maintain the reference count yourself, if you are running in a non-garbage-collection environment:
[string release];
string = [@"Some text" retain];
However, string literals don't need to be managed, as they get allocated statically and never get deallocated! So the release
and retain
methods are just NOOPs (i.e. no operations). You can safely omit them.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…