I have the following function:
- (NSString *)urlEncodedValue {
NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes(
kCFAllocatorDefault,
(CFStringRef)self,
NULL,
CFSTR("?=&+/\r\n"),
kCFStringEncodingUTF8
);
return [result autorelease];
}
Why is Clang giving me the following complaints?
- 1 Call to function 'CFURLCreateStringByAddingPercentEscapes' returns a Core Foundation object with a +1 retain count (owning reference)
- 2 Object sent -autorelease message
- 3 Object returned to caller as an owning reference (single retain count transferred to caller)
- 4 Object over-autoreleased: object was sent -autorelease but the object has zero (locally visible) retain counts
To the best of my knowledge, this conforms to Apple's guidelines regarding memory management and object ownership. Do I have to explicitly release the object? This error has come up 19 times in my project, all under similar circumstances. What am I doing wrong?