• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [NSView removeFromSuperview] not affecting retain count
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NSView removeFromSuperview] not affecting retain count


  • Subject: Re: [NSView removeFromSuperview] not affecting retain count
  • From: Julian Pellico <email@hidden>
  • Date: Mon, 20 Dec 2004 11:04:30 -0800

> Why do you check this in the first place? Do you suspect that there is
> a leak? What made you suspicious of that? Have you tracked it with
> ObjectAlloc?
Of course; otherwise I wouldn't be printing out retain counts. I do
exactly these things with the MyView:
- allocate a MyViewController which contains a MyView
- add the MyViewController to an array
- release the MyViewController
- make the MyView a subview of another custom view
- call removeFromSuperview on the MyView
- remove the MyViewController from the array

The MyViewController gets dealloc'ed, but the MyView doesn't.

>
> What if you write that method like this:
>
> - (void) removeMyViews
> {
>         for (int i = 0; i < [myViewControllers count]; i++)
>         {
>                 NSView *aView = [[myViewControllers objectAtIndex: i] view];
>                 NSLog(@"--- 1 --- %@ retainCount: %u, superview: %@", aView, [aView
> retainCount], [aView superview]);
>                 [aView removeFromSuperview];
>                 NSLog(@"--- 2 --- retainCount: %u, superview: %@", [aView
> retainCount], [aView superview]);
>         }
>         [myViewControllers removeAllObjects];
> }
>
> Does it make any difference if you replace "removeFromSuperview" with
> "removeFromSuperviewWithoutNeedingDisplay"?
I forgot to try these things when I was at home -- I'll do this tonight.

> My advice is always that you shouldn't try to track retain count like
> that. What if it's autoreleased?
It would hardly be safe for the frameworks to autorelease it. I might
want that NSView well past the end of the run loop.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: [NSView removeFromSuperview] not affecting retain count
      • From: "John C. Randolph" <email@hidden>
    • Re: [NSView removeFromSuperview] not affecting retain count
      • From: mmalcolm crawford <email@hidden>
References: 
 >[NSView removeFromSuperview] not affecting retain count (From: Julian Pellico <email@hidden>)
 >Re: [NSView removeFromSuperview] not affecting retain count (From: j o a r <email@hidden>)

  • Prev by Date: NSMatrix beeping when sheets are running
  • Next by Date: How to animate NSTableView row reordering
  • Previous by thread: Re: [NSView removeFromSuperview] not affecting retain count
  • Next by thread: Re: [NSView removeFromSuperview] not affecting retain count
  • Index(es):
    • Date
    • Thread