What you missed is not the difference in verbosity but the memory management difference.
You often see code like this:
ASIHTTPRequest * requestTmp = [[[ASIHTTPRequest alloc] initWithURL:url];
self.request = requestTmp;
[requestTmp release];
You should consider what is happening if the property is retained and old one released in the setter method.
- What this mean is that you create new
request
, refcount is 1.
self.request = request
, now if setRequest
looks like:
- (void)setRequest:(ASIHTTPRequest*)aReq
{
[aReq retain];
[request release];
request = aReq;
}
This means that the object retained the requestTmp
you passed in and released the old one. Refcount of requestTmp
is now 2.
After this call you can then release your original requestTmp
that you created and you are safe because the object retained the requestTmp
- refcount is still 1.
However if you do this:
self.request = [[ASIHTTPRequest alloc] initWithURL:url];
[self.request release];
you end up releasing the request
that the object retained
for its use. Note that you are release object's internal request
where in the original case you released the tmp
but the object keeps it's own retained reference.
So the result is different from the original code.