Re: How can I hide an NSView properly?
Re: How can I hide an NSView properly?
- Subject: Re: How can I hide an NSView properly?
- From: Christophe Dore <email@hidden>
- Date: Fri, 01 Mar 2002 09:39:13 +0100
Absolutly avoid :
[superView addSubView:[indicator release]];
as the release will occur ***before*** the object being added, thus
retained by the superview.
this means that if prior to the line, the retain count of 'indicator' is
1, you add a freed object to the superview. App crashing will certainly
comme soon.
[superView addSubView:indicator];
[indicator release];
may look longer, less fun because less obfuscated, but it will work.
Gerben Wierda wrote:
I have some NSViews (in fact NSProgressIndicators) that I want to
hide/unhide as they must temporarily take the place of other display
items. What I came up with is this:
In owner of nib file init:
Store the superview
[retain the indicator]
In owner of nib file dealloc:
[release the indicator]
For hiding (this releases the indicator, hence the init retains):
[[indicator retain] removeFromSuperviewWithoutNeedingDisplay]
For unhiding (this retains the indicators):
[superView addSubView:[indicator release]];
This will probably work, but I think this fails when the superview is
resized when the indicator is hidden. So this method will probably
mean that I have to give up on a resizable window (or do a lot of
calculation).
I haven't been able to find hide/unhide methods for views (or even
controls). Am I overlooking something?
Thanks,
G
_______________________________________________
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.
_______________________________________________
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.