When should one call unbind:? (in a GC application)
When should one call unbind:? (in a GC application)
- Subject: When should one call unbind:? (in a GC application)
- From: "Sean McBride" <email@hidden>
- Date: Wed, 31 Oct 2007 15:03:23 -0400
- Organization: Rogue Research
For a long time, Apple recommended calling -unbind in a view's -dealloc
method. With the introduction of garbage collection, this had to
change. The new Apple recommendation became:
- (void)viewWillMoveToSuperview:(NSView*)newSuperview
{
[super viewWillMoveToSuperview:newSuperview];
if (newSuperview == nil)
{
[self unbind:...];
}
}
as documented here:
<http://homepage.mac.com/mmalc/CocoaExamples/controllers.html#unbinding>
Apple highly discourages doing work in -finalize, so this seems like a
good idea.
However, if you use 10.5's new NSView API:
- (BOOL)enterFullScreenMode:(NSScreen*)screen
withOptions:(NSDictionary*)options
then the unbinding is triggered, because viewWillMoveToSuperview: is
called with nil. Obviously, we don't want everything unbound, just
because we are fullscreen.
Now I don't know where to call -unbind. Doing it in -finalize seems
dangerous, what with Apple discouraging it so much.
This is <rdar://5497135> BTW.
Thanks,
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden