On Fri, 13 Aug 2010 13:38:59 -0400, Michael Ash <michael....@gmail.com> said: >On Thu, Aug 12, 2010 at 10:51 PM, yanghb <sprh...@gmail.com> 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 = m...@tidbits.com, <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 (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com