i got a report from my analyser that this function could potentially be leaking. Can anyone shed any light as to why?
- (NSString *)encodeString:(NSString *)string {
NSString *newString = NSMakeCollectable([(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)) autorelease]);
return newString;
}
The analyser’s suggestions about memory management aren’t 100% accurate – this is why it uses the phrase “potentially be leaking”. Don’t forget that this analysis runs on the code and is not a runtime check. If you wish to make sure that this line doesn’t leak, check this in instruments.