On May 19, 2016, at 2:10 PM, Jens Alfke wrote:

> 
>> On May 19, 2016, at 9:54 AM, Alex Zavatone <[email protected]> wrote:
>> 
>> OK, fair enough.  Looks like I'll have build a little weak referenced dealy 
>> that subclasses dealloc and stops if it detects any observers. 
> 
> Holy crap, don’t do that. First, you can’t stop a dealloc. Instead you’d have 
> to override retain and release, which is very tricky and will break ARC. 
> Second, needing to do this is a sure sign that You’re Doing It Wrong — it’s 
> like one of those images captioned FAIL where someone’s done some crime 
> against nature using duct tape.

I have no means to see why this is happening at this point.  If I have sinned 
against nature or if nature is sinning against me, I can't tell yet; duct tape 
be damned.

> What is the problem exactly? Who is observing what?

In this case, I'm trying to see what is causing this deallocation.  In my code, 
I explicitly remove the observer before I nil the object, so I don't know where 
this is happening.  

On iOS, part of my app downloads files over https using NSURLSession.  Not a 
problem.  In a manager class, I perform this operation "get the list of files 
from our web end point and then download everything one file at a time 
asynchronously".  I thought it would be fun to use KVO to observe when the 
downloaded file is saved into its final path and then iterate to the next item 
in the list. However, when I switch to one of our pre release web end points, 
we use self signed certs and I haven't had the time to implement the 
challenge/response code yet.  This causes the NSURLSession to clear itself 
somehow.  Now that a failure case has reared its ugly head, I'd like to know 
why the object is removing itself before I am removing the observer.

I want to catch the point where dealloc is being called and the object is still 
being observed, so I can see why this is happening on this failure case.

> —Jens

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to