Using the build and analyze of XCode I saw i have a memory leak in my code:
- (NSString *) doIt
{
NSString *var = [[NSString alloc] init];
return var;
}
This is of course a simplified snippet of my problem
where do i release the object?
This is a perfect situation for autorelease
.
return [var autorelease];
will return the object with its present retain count of 1 and decrement the retain count of the object at some point in the future, after which the calling code should have retained the object if it needs to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With