I'm using ASIHTTPRequest library and I want to be sure if I use it in a good way from the memory management point of view. I create:
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:someUrl];
I guess that according to the naming convention I don't have to retain request object, right? but when I look at the code of requestWithURL:someUrl method I can see:
+ (id)requestWithURL:(NSURL *)newURL
{
return [[[self alloc] initWithURL:newURL] autorelease];
}
so the returned object is autoreleased. Shouldn't I retain it in my code?
In general no - as it is autoreleased, its retained by the autorelease pool and that will release it when it goes out of scope. However, you can retain and then release it if you are in a situation where you need the extra security that provides.