• 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: views removed from their superviews are automatically released?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: views removed from their superviews are automatically released?


  • Subject: Re: views removed from their superviews are automatically released?
  • From: Chris Rudolph <email@hidden>
  • Date: Wed, 20 Mar 2002 09:15:46 -0800

On 3/20/02 5:07 AM, "Bob Newhart" <email@hidden> wrote:

> Well, this may be a silly question, but is your view actually embedded
> in a superview?
>
> Jason
>
>> -----Original Message-----
>> From: email@hidden
>> [mailto:email@hidden] On Behalf Of Andrea Perego
>> Sent: Wednesday, March 20, 2002 3:45 AM
>> To: email@hidden
>> Subject: views removed from their superviews are
>> automatically released?
>>
>>
>> Hi!
>>
>> NSView's documentation about "removeFromSuperview" reads:
>>
>>>
>>> removeFromSuperview
>>>
>>> - (void)removeFromSuperview
>>>
>>> Unlinks the receiver from its superview and its NSWindow, removes it
>>> from the responder chain, and invalidates its cursor rectangles. The
>>> receiver is also released; if you plan to reuse it, be sure to
>>> retain it before sending this message and to release it as
>>> appropriate when adding it as a subview of another NSView.
>>
>> which implies that the removed view is released. A quick search in
>> the archives of this list revealed nothing against this assumption.
>> Nevertheless, while
>> experimenting on a project of mine, I found a situation where this
>> release seems not to happen. To be sure, I bracketed my call with
>> "NSLog":
>>
>>> NSLog(@"before removing from superv. retcount for
>>> view=%d",[paramOptionsView retainCount]);
>>> [paramOptionsView removeFromSuperview];
>>> NSLog(@"after removing from superv. retcount for
>>> view=%d",[paramOptionsView retainCount]);
>>
>> and the corresponding output is:
>>
>>> 2002-03-20 10:24:51.149 testspectra1[528] before removing from
>>> superv. retcount for view=1
>>> 2002-03-20 10:24:51.149 testspectra1[528] after removing from
>>> superv. retcount for view=1
>>

The view was held in the superview array of subviews. This object when
removed from the array will be autoreleased. You retain count will not go
down until the AutoReleasePool is released - next time through the run loop.

Regards,
Chris.

--
Chris Rudolph, Apple Computer, Inc.
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >RE: views removed from their superviews are automatically released? (From: "Bob Newhart" <email@hidden>)

  • Prev by Date: Re: NSString from .txt file
  • Next by Date: Re: Script commands and the application object
  • Previous by thread: RE: views removed from their superviews are automatically released?
  • Next by thread: Re: views removed from their superviews are automatically released?
  • Index(es):
    • Date
    • Thread