Re: Does autoreleased NSURLConnection object guarantee job completion?
Re: Does autoreleased NSURLConnection object guarantee job completion?
- Subject: Re: Does autoreleased NSURLConnection object guarantee job completion?
- From: Matt Neuburg <email@hidden>
- Date: Tue, 17 Aug 2010 09:41:52 -0700
- Thread-topic: Does autoreleased NSURLConnection object guarantee job completion?
On Fri, 13 Aug 2010 13:38:59 -0400, Michael Ash <email@hidden>
said:
>On Thu, Aug 12, 2010 at 10:51 PM, yanghb <email@hidden> wrote:
>> if the instance is released in delegate, what to perform the following
>> code?OK, maybe code segment will always be there, but if the code
>> access some instance vairable, it just will cause EXEC_ACCESS_BAD,
>> isn't it?
>
>This is absolutely correct. If you're going to release an object from
>inside a delegate callback made by that object (which is *usually*
>something you should avoid anyway), then use autorelease, rather than
>release, to ensure that the object has a chance to finish its own code
>before being destroyed.
Sorry to keep harping on this, but the way most users are going to create
their code is by copying and pasting Apple's own example at
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/URLLoa
dingSystem/Tasks/UsingNSURLConnection.html
which goes like this (irrelevant parts omitted):
NSURLConnection *theConnection=[[NSURLConnection alloc]
initWithRequest:theRequest delegate:self];
...
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
...
[connection release];
}
If this paradigm is correct, people should stop saying it isn't. If it
isn't, Apple should not be using it as its primary example.
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden