I've got something this in my code, which is run several times by the app:

        UIView *subView = [[MyView alloc] initWithFrame:frame];
        [theView addSubview:subView];
        [subView release];

Later on this happens:

        [subView removeFromSuperView];
        subView = nil;

These two code snippets are in different controller methods. I'm certain they're called the same number of times.

The docs say that subView gets a release message when removeFromSuperview is called. But the NSLog statement I put in the dealloc method for MyView is never called. The ObjectAlloc instrument shows the count of MyView instances increasing by 1 each time the code is run. And the Leaks instrument shows no leaks at all.

Just to see what would happen, I put [subView release] after the call to removeFromSuperview. My NSLog statement was then called twice; and of course I got an EXC_BAD_ACCESS as well.

I really want to get rid of these subView objects. Why aren't they being deallocated? And since they're not, why am I not getting any leaks when I set subView = nil?

dkj
_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to