Reusing a NSString variable - does it cause a memory leak?
- by Chris S
Coming from a .NET background I'm use to reusing string variables for storage, so is the code below likely to cause a memory leak? The code is targeting OS X on the iphone/itouch so no automatic GC.
-(NSString*) stringExample
{
NSString *result = @"example";
result = [result stringByAppendingString:@" test"]; // where does "example" go?
return result;
}
What confuses me is an NSStrings are immutable, but you can reuse an 'immutable' variable with no problem.