Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When should one call unbind:? (in a GC application)




On Oct 31, 2007, at 2:03 PM, Sean McBride wrote:

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.


I haven't played around with viewWillMoveToSuperview:, but I do a fair amount of work in viewWilMoveToWindow: and viewDidMoveToWindow. Perhaps those APIs will give you the proper hook?


___________________________________________________________ Ricky A. Sharp mailto:email@hidden Instant Interactive(tm) http://www.instantinteractive.com

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >When should one call unbind:? (in a GC application) (From: "Sean McBride" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.