Memory management for NSURLConnection

Posted by eman on Stack Overflow See other posts from Stack Overflow or by eman
Published on 2010-03-22T05:58:27Z Indexed on 2010/03/22 6:01 UTC
Read the original article Hit count: 744

Sorry if this has been asked before, but I'm wondering what the best memory management practice is for NSURLConnection. Apple's sample code uses -[NSURLConnection initWithRequest:delegate:] in one method and then releases in connection:didFailWithError: or connectionDidFinishLoading:, but this spits out a bunch of analyzer warnings and seems sort of dangerous (what if neither of those methods is called?).

I've been autoreleasing (using +[NSURLConnection connectionWithRequest:delegate:]), which seems cleaner, but I'm wondering--in this case, is it at ever possible for the NSURLConnection to be released before the connection has closed?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cocoa