I have written a method (shown below). The project is compiled using ARC, but the file the method is in has to be compiled with the -fno-objc-arc switch because of a third party library dependency.
The leak inspector is telling me that there is a leak on
return [fragments componentsJoinedByString:@" "];
I can’t see it – could I ask for another pair of eyes to point out the error of my ways?
Many thanks
-(NSString *)trimAndTidy:(NSString *)aString
{
NSCharacterSet *nsc = [NSCharacterSet characterSetWithCharactersInString:@"\r\n \t"];
NSString *fragment;
NSMutableArray *fragments = [NSMutableArray array];
NSScanner *scanner = [NSScanner scannerWithString:aString];
do
{
if ([scanner scanUpToCharactersFromSet:nsc intoString:&fragment])
[fragments addObject:fragment];
}
while (![scanner isAtEnd]);
return [fragments componentsJoinedByString:@" "];
}
The leak inspector tells you where a leak was allocated and not where the leak was caused.
To find the cause, you have to find the extra
retainor missingreleasecall.