On Wed, 7 Jul 2010 17:54:58 -0400, Michael Ash <michael....@gmail.com> said:
>> I get a false positive in *any*
>> of my apps that uses NSURLConnection, for example:
>>
>> NSURLConnection* con = [[NSURLConnection alloc] initWithRequest:req
>> delegate:self];
>>
>> That triggers a "potential leak" warning. Well, of course it is a
>> *potential* leak. But it isn't a *real* leak, because I happen to know that
>> I'm going to release this object in either connection:didFailWithError: or
>> connectionDidFinishLoading:. (My code and memory management come right out
>> of Apple's own examples here.) I know how NSURLConnections work; the static
>> analyzer doesn't. But I would hardly call that a bug.
>
>I would call it potentially dangerous code. It's much better, IMO, to
>place the connection into an instance variable and that way balance
>all of your retains and releases. Each exception to the standard
>memory management pattern that you make increases the odds of screwing
>something up.

Yes, I agree, and I did think of doing that to see if it would silence the
warning. But a beginner might not realize that - and, as I say, my code is
copied and pasted right out of Apple's example; it's up to Apple to change
the example if it's dangerous...

http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/URL
LoadingSystem/Tasks/UsingNSURLConnection.html

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

Reply via email to