I have a routine that parses text via a loop. At the end of each record I need to clear my string variables but I read that someString = @”” actually just points to a new string & causes a memory leak.
What is the best way to handle this? Should I rather use mutable string vars and use setString:@”” between iterations?
You have to be careful in which case you create the NSString: (factory method) or (alloc init or (using @””).
If you use @””, it is a constant string, see here: Constant NSString
If you use [[NSString alloc] init], you need to release it.You just need to do [someString release].
If you use something like [NSString stringWithFormat:@””], you don’t need to release it because it is already auto released by runtime