• 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: When should one call unbind:? (in a GC application)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Subject: Re: When should one call unbind:? (in a GC application)
  • From: Ricky Sharp <email@hidden>
  • Date: Wed, 31 Oct 2007 15:15:07 -0500


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:
This email sent to email@hidden


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

  • Prev by Date: Re: Collection was mutated while being enumerated
  • Next by Date: Re: Collection was mutated while being enumerated
  • Previous by thread: When should one call unbind:? (in a GC application)
  • Next by thread: Create NSImage from array of integers
  • Index(es):
    • Date
    • Thread