Re: Crash from NSURLConnection if delegate released too soon?
Re: Crash from NSURLConnection if delegate released too soon?
- Subject: Re: Crash from NSURLConnection if delegate released too soon?
- From: Howard Moon <email@hidden>
- Date: Mon, 25 Aug 2014 15:05:00 -0700
On Aug 25, 2014, at 2:13 PM, Jens Alfke <email@hidden> wrote:
>
>> On Aug 25, 2014, at 1:43 PM, Howard Moon <email@hidden> wrote:
>>
>> The Apple docs show simply setting the connection and receivedData to nil, instead of calling release on them.
>
> Do you have a strong [sic] reason to be using manual retain/release? If not, I'd _really_ recommend switching to ARC, at least for this one source file, especially since it sounds like you don't have the memory-management rules firmly memorized yet.
>
I've never used or looked into ARC at all. I'm on a tight deadline, so switching to a new way of doing things might not be advisable at this point.
I'm guessing that the setting to nil in the newest Apple docs *assumes* I'm using ARC, then? They might mention that somewhere.
I'm pretty sure I only release those things that I alloc (or copy). I don't have any problems with other Cocoa classes I'm using. The only issue seems to be this NSURLConnection object. And what's been confusing me is apparently this mixing of examples using ARC and not.
> Have you run the static analyzer (Cmd-Shift-B)? It's good at finding and explaining ref-counting mistakes.
>
Yes, and it shows a "potential leak" for theConnection if I don't call release on it explicitly in the launching function, even though it is released in the completion and error functions. Nothing else is noted in this file (or any related files).
> Have you tried using NSZombie? That's a good way to track down over-released objects at runtime. (See Technical Note TN2239, iOS Debugging Magic.)
>
Not yet. (I'm writing desktop software, by the way, not iOS stuff.)
> —Jens
_______________________________________________
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